Closed nichtich closed 12 months ago
Agree, it is a technical debt of the project.
Here is a basic usage of Monolog:
use Monolog\Level;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('path/to/your.log', Level::Warning));
// add records to the log
$log->warning('Foo');
$log->error('Bar');
The 'path/to/your.log'
part could be read from configuration, but what would you like to see as default value, something like log/qa-catalogue.log
?
There will be two new configuration parameters:
logFile
, logFile[id]
: (string) a path of the log file. Default value: logs/qa-catalogue.log
.logLevel
, logLevel[id]
: (string) the minimal logging level. Possible values are: DEBUG
, INFO
, NOTICE
, WARNING
, ERROR
, CRITICAL
, ALERT
, EMERGENCY
. If you set WARNING
you will not receive DEBUG
, INFO
, and NOTICE
messages. Default: WARNING
.We will use 2.5 for the time being because it supports PHP 7.2. monolog 3.x supports PHP 8.x only.
composer require monolog/monolog:^2.5
I've extened the logger to use error_log
by default and configurable to log to a file. Other methods such as syslog
may be added if needed.
@nichtich Thanks! However I do not see your commits. Did you pushed them?
See #de3bd88718cc0b
Sorry, I checked the main. Now I have reviewed it and merged to the main via a PR.
error_log
is used in some places for tracing and debugging. Configuration should include settings for log level and internally use a PSR-3 compatible logging library such as Monolog, e.g.For debugging, the log level would be changed in configuration. Logging target could be
stderr
(error_log, the default as now),file
, andsyslog
, this should be enough to support.