Automattic\WooCommerce\Internal\Admin\Logging

LogHandlerFileV2::handle()publicWC 1.0

Handle a log entry.

Method of the class: LogHandlerFileV2{}

No Hooks.

Return

true|false. False if value was not handled and true if value was handled.

Usage

$LogHandlerFileV2 = new LogHandlerFileV2();
$LogHandlerFileV2->handle( $timestamp, $level, $message, $context );
$timestamp(int) (required)
Log timestamp.
$level(string) (required)
emergency|alert|critical|error|warning|notice|info|debug.
$message(string) (required)
Log message.
$context(array) (required)

Additional information for log handlers. Any data can be added here, but there are some array keys that have special behavior.

  • source(string)
    Determines which log file to write to. Must be at least 3 characters in length.

  • backtrace(true|false)
    True to include a backtrace that shows where the logging function got called.

LogHandlerFileV2::handle() code WC 9.3.3

public function handle( $timestamp, $level, $message, $context ) {
	if ( isset( $context['source'] ) && is_string( $context['source'] ) && strlen( $context['source'] ) >= 3 ) {
		$source = sanitize_title( trim( $context['source'] ) );
	} else {
		$source = $this->determine_source();
	}

	$entry = static::format_entry( $timestamp, $level, $message, $context );

	$written = $this->file_controller->write_to_file( $source, $entry, $timestamp );

	if ( $written ) {
		$this->file_controller->invalidate_cache();
	}

	return $written;
}