Download the PHP package bayfrontmedia/multi-logger without Composer
On this page you can find all versions of the php package bayfrontmedia/multi-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bayfrontmedia/multi-logger
More information about bayfrontmedia/multi-logger
Files in bayfrontmedia/multi-logger
Package multi-logger
Short Description An easy-to-use library used to manage multiple Monolog channels from a single class.
License MIT
Homepage https://github.com/bayfrontmedia/multi-logger
Informations about the package multi-logger
Multi-Logger
An easy-to-use library used to manage multiple Monolog channels from a single class.
- License
- Author
- Requirements
- Installation
- Usage
License
This project is open source and available under the MIT License.
Author
Requirements
- PHP
^8.0
Installation
Usage
NOTE: All exceptions thrown by Multi-Logger extend Bayfront\MultiLogger\Exceptions\MultiLoggerException
, so you can choose to catch exceptions as narrowly or broadly as you like.
Multi-Logger exists in order manage multiple Monolog channels from a single class.
In some cases, you may still need to interact with the Monolog\Logger
object directly, and Multi-Logger allows you to do that via the getChannel method.
A Logger
instance must be passed to the constructor, and will automatically be set as the default and current channel.
To aid in consistency when referencing log channels, the Bayfront\MultiLogger\ChannelName
class contains constants with suggested channel names, including:
APP
AUDIT
CLI
DATABASE
CONTROLLER
DEV
ERROR
HEALTH
HTTP
JOB
MODEL
NOTIFICATION
OPS
PRIVILEGES
PROD
QA
QUEUE
REQUEST
RESPONSE
ROUTER
SCHEDULE
SECURITY
STAGING
STORAGE
Example:
Public methods
- getChannels
- getDefaultChannel
- getCurrentChannel
- addChannel
- isChannel
- getChannel
- channel
Logging events
- emergency
- alert
- critical
- error
- warning
- notice
- info
- debug
- log
getChannels
Description:
Return array of channel names.
Parameters:
- (None)
Returns:
- (array)
getDefaultChannel
Description:
Return name of default channel.
Parameters:
- (None)
Returns:
- (string)
getCurrentChannel
Description:
Return name of current channel.
Parameters:
- (None)
Returns:
- (string)
addChannel
Description:
Add a logger instance as a new channel with the same name.
If an existing instance exists with the same name, it will be overwritten.
Parameters:
$logger
(object):Monolog\Logger
object
Returns:
- (self)
Example:
isChannel
Description:
Does channel name exist?
Parameters:
$channel
(string)
Returns:
- (bool)
Example:
getChannel
Description:
Returns Logger
instance for a given channel.
Parameters:
$channel = ''
(string): Name of channel to return. If empty string, the current channel will be returned.
Returns:
- (object):
Monolog\Logger
object
Throws:
Bayfront\MultiLogger\Exceptions\ChannelNotFoundException
Example:
channel
Description:
Set the channel name to be used for the next logged event.
By default, all logged events will be logged to the default channel used in the constructor.
Parameters:
$channel
(string)
Returns:
- (self)
Throws:
Bayfront\MultiLogger\Exceptions\ChannelNotFoundException
Example:
emergency
Description:
System is unusable.
Parameters:
$message
(string)$context
(array)
Returns:
- (void)
alert
Description:
Action must be taken immediately.
Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
Parameters:
$message
(string)$context
(array)
Returns:
- (void)
critical
Description:
Critical conditions.
Example: Application component unavailable, unexpected exception.
Parameters:
$message
(string)$context
(array)
Returns:
- (void)
error
Description:
Runtime errors that do not require immediate action but should typically be logged and monitored.
Parameters:
$message
(string)$context
(array)
Returns:
- (void)
warning
Description:
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
(string)$context
(array)
Returns:
- (void)
notice
Description:
Normal but significant events.
Parameters:
$message
(string)$context
(array)
Returns:
- (void)
info
Description:
Interesting events.
Example: User logs in, SQL logs.
Parameters:
$message
(string)$context
(array)
Returns:
- (void)
debug
Description:
Detailed debug information.
Parameters:
$message
(string)$context
(array)
Returns:
- (void)
log
Description:
Logs with an arbitrary level.
Parameters:
$level
(mixed)$message
(string)$context
(array)
Returns:
- (void)