Constants

DEBUG

DEBUG = 100

Detailed debug information

INFO

INFO = 200

Interesting events

Examples: User logs in, SQL logs.

NOTICE

NOTICE = 250

Uncommon events

WARNING

WARNING = 300

Exceptional occurrences that are not errors

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

ERROR

ERROR = 400

Runtime errors

CRITICAL

CRITICAL = 500

Critical conditions

Example: Application component unavailable, unexpected exception.

ALERT

ALERT = 550

Action must be taken immediately

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

EMERGENCY

EMERGENCY = 600

Urgent alert.

API

API = 1 : integer

Monolog API version

This is only bumped when API breaks are done and should follow the major version of the library

Properties

$levels

$levels : array

Logging levels from syslog protocol defined in RFC 5424

Type

array — Logging levels

$timezone

$timezone : \DateTimeZone

Type

\DateTimeZone

$name

$name : string

Type

string

$processors

$processors : array<mixed,callable>

Processors that will process all log records

To process records of a single handler instead, add the processor on that specific handler

Type

array<mixed,callable>

$microsecondTimestamps

$microsecondTimestamps : boolean

Type

boolean

Methods

__construct()

__construct(string  $name, array<mixed,\Monolog\Handler\HandlerInterface>  $handlers = array(), array<mixed,callable>  $processors = array()) 

Parameters

string $name

The logging channel

array<mixed,\Monolog\Handler\HandlerInterface> $handlers

Optional stack of handlers, the first one in the array is called first, etc.

array<mixed,callable> $processors

Optional array of processors

getName()

getName() : string

Returns

string

withName()

withName(  $name) : static

Return a new cloned instance with the name changed

Parameters

$name

Returns

static

pushHandler()

pushHandler(\Monolog\Handler\HandlerInterface  $handler) : $this

Pushes a handler on to the stack.

Parameters

\Monolog\Handler\HandlerInterface $handler

Returns

$this

setHandlers()

setHandlers(array<mixed,\Monolog\Handler\HandlerInterface>  $handlers) : $this

Set handlers, replacing all existing ones.

If a map is passed, keys will be ignored.

Parameters

array<mixed,\Monolog\Handler\HandlerInterface> $handlers

Returns

$this

pushProcessor()

pushProcessor(callable  $callback) : $this

Adds a processor on to the stack.

Parameters

callable $callback

Returns

$this

popProcessor()

popProcessor() : callable

Removes the processor on top of the stack and returns it.

Returns

callable

getProcessors()

getProcessors() : array<mixed,callable>

Returns

array<mixed,callable>

useMicrosecondTimestamps()

useMicrosecondTimestamps(boolean  $micro) 

Control the use of microsecond resolution timestamps in the 'datetime' member of new records.

Generating microsecond resolution timestamps by calling microtime(true), formatting the result via sprintf() and then parsing the resulting string via \DateTime::createFromFormat() can incur a measurable runtime overhead vs simple usage of DateTime to capture a second resolution timestamp in systems which generate a large number of log events.

Parameters

boolean $micro

True to use microtime() to create timestamps

addRecord()

addRecord(integer  $level, string  $message, array  $context = array()) : Boolean

Adds a log record.

Parameters

integer $level

The logging level

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

addDebug()

addDebug(string  $message, array  $context = array()) : Boolean

Adds a log record at the DEBUG level.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

addInfo()

addInfo(string  $message, array  $context = array()) : Boolean

Adds a log record at the INFO level.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

addNotice()

addNotice(string  $message, array  $context = array()) : Boolean

Adds a log record at the NOTICE level.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

addWarning()

addWarning(string  $message, array  $context = array()) : Boolean

Adds a log record at the WARNING level.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

addError()

addError(string  $message, array  $context = array()) : Boolean

Adds a log record at the ERROR level.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

addCritical()

addCritical(string  $message, array  $context = array()) : Boolean

Adds a log record at the CRITICAL level.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

addAlert()

addAlert(string  $message, array  $context = array()) : Boolean

Adds a log record at the ALERT level.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

addEmergency()

addEmergency(string  $message, array  $context = array()) : Boolean

Adds a log record at the EMERGENCY level.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

getLevels()

getLevels() : array

Gets all supported logging levels.

Returns

array —

Assoc array with human-readable level names => level codes.

getLevelName()

getLevelName(integer  $level) : string

Gets the name of the logging level.

Parameters

integer $level

Returns

string

toMonologLevel()

toMonologLevel(  $level) : integer

Converts PSR-3 levels to Monolog ones if necessary

Parameters

$level

Returns

integer

isHandling()

isHandling(integer  $level) : Boolean

Checks whether the Logger has a handler that listens on the given level

Parameters

integer $level

Returns

Boolean

log()

log(mixed  $level, string  $message, array  $context = array()) : Boolean

Adds a log record at an arbitrary level.

This method allows for compatibility with common interfaces.

Parameters

mixed $level

The log level

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

debug()

debug(string  $message, array  $context = array()) : Boolean

Adds a log record at the DEBUG level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

info()

info(string  $message, array  $context = array()) : Boolean

Adds a log record at the INFO level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

notice()

notice(string  $message, array  $context = array()) : Boolean

Adds a log record at the NOTICE level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

warn()

warn(string  $message, array  $context = array()) : Boolean

Adds a log record at the WARNING level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

warning()

warning(string  $message, array  $context = array()) : Boolean

Adds a log record at the WARNING level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

err()

err(string  $message, array  $context = array()) : Boolean

Adds a log record at the ERROR level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

error()

error(string  $message, array  $context = array()) : Boolean

Adds a log record at the ERROR level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

crit()

crit(string  $message, array  $context = array()) : Boolean

Adds a log record at the CRITICAL level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

critical()

critical(string  $message, array  $context = array()) : Boolean

Adds a log record at the CRITICAL level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

alert()

alert(string  $message, array  $context = array()) : Boolean

Adds a log record at the ALERT level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

emerg()

emerg(string  $message, array  $context = array()) : Boolean

Adds a log record at the EMERGENCY level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

emergency()

emergency(string  $message, array  $context = array()) : Boolean

Adds a log record at the EMERGENCY level.

This method allows for compatibility with common interfaces.

Parameters

string $message

The log message

array $context

The log context

Returns

Boolean —

Whether the record has been processed

setTimezone()

setTimezone(\DateTimeZone  $tz) 

Set the timezone to be used for the timestamp of log records.

This is stored globally for all Logger instances

Parameters

\DateTimeZone $tz

Timezone object