Logger
in package
This is a Singleton implementation of a Monolog\Logger. This will log to all the 'correct' places for the application, without having to always set up same Handlers.
The limitation here is that we have a limited number of 'channels' and the user of the logger need to know them. This is loosely based off a Monolog log registry
Allows global access to the Logger
instance that ThinkIQ uses. This can be used in scripts, product code, etc.
TiqUtilities\Logger::get()->info('Application has started!');
TiqUtilities\Logger::get('material_ledger')->warning('Account does not exist');
Table of Contents
Constants
- ALLOWED_LOGGERS = ['core', 'material_ledger', 'sql']
- All the allowed loggers that can be used. This will limit a proliferation of channels in the log files.
Properties
- $loggers : array<string|int, Logger>
- List of all loggers in the registry (by named indexes)
Methods
- addLogger() : void
- Adds new logging channel to the registry
- get() : Logger
- Gets Logger instance from the registry
- __construct() : mixed
- This is a Singleton, you cannot create new instances
- initializeLoggers() : void
- Sets up the different loggers that will always be present, and their Monolog\Handlers. This will behave differently in the script engine
Constants
ALLOWED_LOGGERS
All the allowed loggers that can be used. This will limit a proliferation of channels in the log files.
public
mixed
ALLOWED_LOGGERS
= ['core', 'material_ledger', 'sql']
Properties
$loggers
List of all loggers in the registry (by named indexes)
protected
static array<string|int, Logger>
$loggers
= []
Methods
addLogger()
Adds new logging channel to the registry
public
static addLogger(Logger $logger[, string|null $name = null ][, bool $overwrite = false ]) : void
Parameters
- $logger : Logger
-
Instance of the logging channel
- $name : string|null = null
-
Name of the logging channel ($logger->getName() by default)
- $overwrite : bool = false
-
Overwrite instance in the registry if the given name already exists?
get()
Gets Logger instance from the registry
public
static get([string $name = 'core' ]) : Logger
Parameters
- $name : string = 'core'
-
Name of the requested Logger instance
Tags
Return values
Logger__construct()
This is a Singleton, you cannot create new instances
protected
__construct() : mixed
initializeLoggers()
Sets up the different loggers that will always be present, and their Monolog\Handlers. This will behave differently in the script engine
protected
static initializeLoggers() : void