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.
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.
Methods
fromName()
public
static fromName(string $name) : static
Parameters
- $name : string
Return values
staticfromValue()
public
static fromValue(int $value) : static
Parameters
- $value : int
Return values
staticgetName()
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
stringincludes()
Returns true if the passed $level is higher or equal to $this
public
includes(Level $level) : bool
Parameters
- $level : Level
Return values
boolisHigherThan()
public
isHigherThan(Level $level) : bool
Parameters
- $level : Level
Return values
boolisLowerThan()
public
isLowerThan(Level $level) : bool
Parameters
- $level : Level
Return values
booltoPsrLogLevel()
Returns the PSR-3 level matching this instance
public
toPsrLogLevel() : string
Tags
Return values
stringtoRFC5424Level()
Returns the RFC 5424 level matching this instance
public
toRFC5424Level() : int