Overview

Namespaces

  • None
  • VSP
    • Core
      • Abstracts
      • Interfaces
      • Traits
        • WC_Compatibility
    • Deprecation
    • Helper
    • Modules
      • Addons
      • Logger

Classes

  • Addons
  • Logger
  • Shortcode
  • System_Logs
  • System_Tools
  • WPOnion
  • Overview
  • Namespace
  • Class

Class Logger

Class VSP_Logger

VSP\Modules\Logger implements VSP\Core\Interfaces\Logger
Namespace: VSP\Modules
Author: Varun Sridharan varunsridharan23@gmail.com
Located at includes/modules/class-logger.php
Methods summary
public
# __construct( array $handlers = null, string $threshold = null )

Constructor for the logger.

Constructor for the logger.

Parameters

$handlers

Optional. Array of log handlers. If $handlers is not provided, the filter 'vsp_register_log_handlers' will be used to define the handlers. If $handlers is provided, the filter will not be applied and the handlers will be used directly.

$threshold

Optional. Define an explicit threshold. May be configured via VSP_LOG_THRESHOLD. By default, all logs will be processed.

public
# log_errors( )

Ensures fatal errors are logged so they can be picked up in the status report.

Ensures fatal errors are logged so they can be picked up in the status report.

public
# critical( string $message, array $context = array() )

Adds a critical level message.

Adds a critical level message.

Critical conditions. Example: Application component unavailable, unexpected exception.

Parameters

$message
$context

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::critical()
public
# log( string $level, string|array $message, array $context = array() )

Add a log entry.

Add a log entry.

Parameters

$level

One of the following: '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
Optional. Additional information for log handlers.

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::log()
protected boolean
# should_handle( string $level )

Determine whether to handle or ignore log.

Determine whether to handle or ignore log.

Parameters

$level
emergency|alert|critical|error|warning|notice|info|debug

Returns

boolean
True if the log should be handled.
public
# emergency( string|array $message, array $context = array() )

Adds an emergency level message.

Adds an emergency level message.

System is unusable.

Parameters

$message
$context

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::emergency()
public
# alert( string|array $message, array $context = array() )

Adds an alert level message.

Adds an alert level message.

Action must be taken immediately. Example: Entire website down, database unavailable, etc.

Parameters

$message
$context

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::alert()
public
# error( string|array $message, array $context = array() )

Adds an error level message.

Adds an error level message.

Runtime errors that do not require immediate action but should typically be logged and monitored.

Parameters

$message
$context

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::error()
public
# warning( string|array $message, array $context = array() )

Adds a warning level message.

Adds a warning level message.

Exceptional occurrences that are not errors.

Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

Parameters

$message
$context

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::warning()
public
# notice( string|array $message, array $context = array() )

Adds a notice level message.

Adds a notice level message.

Normal but significant events.

Parameters

$message
$context

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::notice()
public
# info( string|array $message, array $context = array() )

Adds a info level message.

Adds a info level message.

Interesting events. Example: User logs in, SQL logs.

Parameters

$message
$context

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::info()
public
# debug( string|array $message, array $context = array() )

Adds a debug level message.

Adds a debug level message.

Detailed debug information.

Parameters

$message
$context

Returns


$this

Implementation of

VSP\Core\Interfaces\Logger::debug()
Properties summary
protected array $handlers

Stores registered log handlers.

Stores registered log handlers.

#
protected integer $threshold

Minimum log level this handler will process.

Minimum log level this handler will process.

#
API documentation generated by ApiGen