WC_Logger::log()publicWC 1.0

Add a log entry.

Метод класса: WC_Logger{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$WC_Logger = new WC_Logger();
$WC_Logger->log( $level, $message, $context );
$level(строка) (обязательный)
One of the following:
php 'emergency': System is unusable. 'alert': Action must be taken immediately. 'critical': Critical conditions. 'error': Error conditions. 'warning': Warning conditions. 'notice': Normal but significant condition. 'info': Informational messages. 'debug': Debug-level messages.
$message(строка) (обязательный)
Log message.
$context(массив)
Additional information for log handlers.
По умолчанию: array()

Код WC_Logger::log() WC 8.7.0

public function log( $level, $message, $context = array() ) {
	if ( ! WC_Log_Levels::is_valid_level( $level ) ) {
		/* translators: 1: WC_Logger::log 2: level */
		wc_doing_it_wrong( __METHOD__, sprintf( __( '%1$s was called with an invalid level "%2$s".', 'woocommerce' ), '<code>WC_Logger::log</code>', $level ), '3.0' );
	}

	if ( $this->should_handle( $level ) ) {
		$timestamp = time();

		foreach ( $this->handlers as $handler ) {
			/**
			 * Filter the logging message. Returning null will prevent logging from occurring since 5.3.
			 *
			 * @since 3.1
			 * @param string $message Log message.
			 * @param string $level   One of: emergency, alert, critical, error, warning, notice, info, or debug.
			 * @param array  $context Additional information for log handlers.
			 * @param object $handler The handler object, such as WC_Log_Handler_File. Available since 5.3.
			 */
			$message = apply_filters( 'woocommerce_logger_log_message', $message, $level, $context, $handler );

			if ( null !== $message ) {
				$handler->handle( $timestamp, $level, $message, $context );
			}
		}
	}
}