pkiraly / qa-catalogue-web

QA Catalogue / A data quality dashboard for MARC catalogues
GNU General Public License v3.0
10 stars 6 forks source link

Add logger #146

Closed nichtich closed 12 months ago

nichtich commented 1 year ago

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.

$config->log->error("...")
$config->log->info("...")
$config->log->debug("...")

For debugging, the log level would be changed in configuration. Logging target could be stderr (error_log, the default as now), file, and syslog, this should be enough to support.

pkiraly commented 1 year ago

Agree, it is a technical debt of the project.

pkiraly commented 1 year ago

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:

pkiraly commented 1 year ago

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
nichtich commented 12 months ago

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.

pkiraly commented 12 months ago

@nichtich Thanks! However I do not see your commits. Did you pushed them?

nichtich commented 12 months ago

See #de3bd88718cc0b

pkiraly commented 12 months ago

Sorry, I checked the main. Now I have reviewed it and merged to the main via a PR.