Documentation

Level : int
in package

Represents the log levels

Monolog supports the logging levels described by RFC 5424 https://datatracker.ietf.org/doc/html/rfc5424 but due to BC the severity values used internally are not 0-7.

To get the level name/value out of a Level there are several options:

  • Use ->getName() to get the standard Monolog name which is full uppercased (e.g. "DEBUG")
  • Use ->toPsrLogLevel() to get the standard PSR-3 name which is full lowercased (e.g. "debug")
  • Use ->toRFC5424Level() to get the standard RFC 5424 value (e.g. 7 for debug, 0 for emergency)
  • Use ->name to get the enum case's name which is capitalized (e.g. "Debug")

To get the internal value for filtering, if the includes/isLowerThan/isHigherThan methods are not enough, you can use ->value to get the enum case's integer value.

Table of Contents

Cases

Alert  = 550
Action must be taken immediately
Critical  = 500
Critical conditions
Debug  = 100
Detailed debug information
Emergency  = 600
Urgent alert.
Error  = 400
Runtime errors
Info  = 200
Interesting events
Notice  = 250
Uncommon events
Warning  = 300
Exceptional occurrences that are not errors

Methods

fromName()  : static
fromValue()  : static
getName()  : string
Returns the monolog standardized all-capitals name of the level
includes()  : bool
Returns true if the passed $level is higher or equal to $this
isHigherThan()  : bool
isLowerThan()  : bool
toPsrLogLevel()  : string
Returns the PSR-3 level matching this instance
toRFC5424Level()  : int
Returns the RFC 5424 level matching this instance

Cases

Debug

Detailed debug information

Info

Interesting events

Examples: User logs in, SQL logs.

Warning

Exceptional occurrences that are not errors

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

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.

Methods

fromName()

public static fromName(string $name) : static
Parameters
$name : string
Return values
static

fromValue()

public static fromValue(int $value) : static
Parameters
$value : int
Return values
static

getName()

Returns the monolog standardized all-capitals name of the level

public getName() : string

Use this instead of $level->name which returns the enum case name (e.g. Debug vs DEBUG if you use getName())

Return values
string

includes()

Returns true if the passed $level is higher or equal to $this

public includes(Level $level) : bool
Parameters
$level : Level
Return values
bool

isHigherThan()

public isHigherThan(Level $level) : bool
Parameters
$level : Level
Return values
bool

isLowerThan()

public isLowerThan(Level $level) : bool
Parameters
$level : Level
Return values
bool

toPsrLogLevel()

Returns the PSR-3 level matching this instance

public toPsrLogLevel() : string
Tags
phpstan-return

\Psr\Log\LogLevel::*

Return values
string

toRFC5424Level()

Returns the RFC 5424 level matching this instance

public toRFC5424Level() : int
Tags
phpstan-return

int<0, 7>

Return values
int

        
On this page

Search results