v6:logging:monolog
The Monolog Logging Service
See Also
This service provides an attachment point for ADOdb to connect to the monolog logging service. A working service must have been previously installed and configured. Once configured, ADOdb can make use of any of the provided services, for example:
- File Logging
- Syslog Logging
- Browser Console Logging
Configuring Target Files
To set up the output streams we use the standard format used in monolog, that is an array of outputs, keyed by the logging level required. The looging levels are defined as follows:
| Level | Integer Value |
|---|---|
| DEBUG | 100 |
| INFO | 200 |
| NOTICE | 250 |
| WARNING | 300 |
| ERROR | 400 |
| CRITICAL | 500 |
| ALERT | 550 |
| EMERGENCY | 600 |
Note that any messages sent to undefined logging levels are ignored
Example Using Monolog
In this example, we will attach a monolog logger to the Core logging service.
use Monolog\Logger; use Monolog\Handler\StreamHandler; use ADOdb\LoggingPlugin\monolog\ADOLogger; $logBase = '/dev/github/logs/'; $debugStreamHandler = new StreamHandler( $logBase . 'debug.log', Logger::DEBUG, $bubble=false); $infoStreamHandler = new StreamHandler( $logBase . 'info.log', Logger::INFO, $bubble=false ); $noticeStreamHandler = new StreamHandler( $logBase . 'notice.log', Logger::NOTICE, $bubble=false ); $errorStreamHandler = new StreamHandler( $logBase . 'error.log', Logger::ERROR, $bubble=false ); $criticalStreamHandler = new StreamHandler( $logBase . 'critical.log', Logger::CRITICAL, $bubble=false); $streamHandlers = array( Logger::DEBUG=>$debugStreamHandler, Logger::INFO=>$infoStreamHandler, Logger::NOTICE=>$noticeStreamHandler, Logger::ERROR=>$errorStreamHandler, Logger::CRITICAL=>$criticalStreamHandler ); $loggingObject = new ADOLogger($streamHandlers,ADOLogger::LOG_FORMAT_JSON); $loggingObject->redirectCoreLogging(true); $db = ADOnewConnection('mysqli'); $db->connect('localhost','user','password','employees'); $loggingObject->setConnectionObject($db); $loggingObject->pushProcessor('MemoryUsageProcessor'); $SQL = "SELECT COUNT(*) FROM employees WHERE employee_no > 'A'"; $employeeCount = $db->getOne($SQL);
v6/logging/monolog.txt · Last modified: by 127.0.0.1
