Logging
Overview¶
As from version 7 the debug option is deprecated (it is no more valid) and we use a new mechanism to debug the code.
GuriddoPHP uses PSR-3 Logger Interface for its logging mechanism See https://www.php-fig.org/psr/psr-3/.
This mean that you can add your own logging class and use it in Guriddo.
By default we use logger, which output the logs to a file.
Warning
Be a sure that the log file specified have a write permission in the directory where it is.
Using the Logger¶
To use the build in logger create the instance before the Render (or queryGrid) class and pass it as third parameter to the Render (queryGrid) class
$logger = new Guriddo\Logger\Logger(__DIR__.'/myLog.log','myName', 'debug' );
$grid = new Guriddo\jqGrid\Render\Render($conn, 'pdo', $logger);
where first parameter is the log file, the second is the channel and the third parameter is the log level.
Log level can have the following values:
- debug
- info
- notice
- warning
- error
- critical
- alert
- emergency
The most used level in Guriddo PHP are: debug, info and error levels.
The outputted log format is: YYYY-mm-dd HH:ii:ss.uuuuuu (loglevel) (channel) (pid:##) Log message content {"Optional":"JSON Contextual Support Data"} {"Optional":"Exception Data"}
Logger options¶
To see all the options and methods related to Logger consult the api doc here(link)
Custom defined Logger¶
To use your own Logger you need to create a class using the PSR-3 logger interface and simple pass it to the Guriddo lib instance like this:
```php
$logger = new MySimple\Logger(...);
$grid = new Guriddo\jqGrid\Render\Render($conn, 'pdo', $logger);