• PHP reference

Logger

class Logger extends ExtendableObject

Simple way to log messages in global scope.

Usage:

Logger::log(Logger::NOTICE, 'Hey man!');

Constants

DEBUG

Detailed debug information.

DEPRECATED

Deprecated function usage.

INFO

Interesting events.

Examples: User logs in, SQL logs.

NOTICE

Uncommon events.

WARNING

Exceptional occurrences that are not errors.

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

ERROR

Runtime errors.

CRITICAL

Critical conditions.

Example: Application component unavailable, unexpected exception.

ALERT

Action must be taken immediately.

Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.

EMERGENCY

Urgent alert.

Properties

static array $levels

Log levels.

integer $min_log_level

Minimal log level.

Methods

static setTag(string $tag, string $value)

Set a logger tag.

Parameters

  • string $tag
  • string $value

static resetTag(string $tag)

Reset a logger tag.

Parameters

  • string $tag

static log($level, $message, string|object $module = '', array $context = [])

Send a message to the application log.

Parameters

  • $level
  • $message
  • string|object $module
  • array $context

Inherited from ExtendableObject

__construct()

Constructor.

final static ExtendableObject instance()

Get instance.

Return Value

final static boolean hasInstance()

Check whether there is an instance of this class available.

Return Value

  • boolean

final boolean extension($extension)

Call class method, if it exists.

Parameters

  • $extension

Return Value

  • boolean