Log library of the Ride framework

1.0.3 2017-03-09 17:25 UTC

This package is auto-updated.

Last update: 2020-11-12 15:42:37 UTC


Log library of the PHP Ride framework.

Logging is used to keep an history of events or to debug an application.

What's In This Library


A log message defines what's being done or what happened.

It consists a:

  • level: error, warning, information or debug
  • title: title of the message
  • description: detailed information about the message
  • date: date and time of the event
  • microtime: microseconds in the application run
  • id: id of the log session
  • source: source library or module which logged the message
  • client: Id of the client (eg. an IP address)


A LogSession is a collection of log messages which belong together. For example, all logged messages from handling the same HTTP request.


The log object is the facade to the library which offers an easy interface to log messages. It uses the observer pattern to dispatch those logged messages to the listeners of the log.


A log listener performs the actual logging of the message. The most common thing to do is write a log message to a file. An implementation to do just that has been provided.


The browseable log listener is an extension of the regular log listener. It adds functionality to retrieve and inspect log messages back from the log.

Code Sample

Check this code sample to see the possibilities of this library:


use ride\library\decorator\LogMessageDecorator;
use ride\library\log\listener\BrowseableFileLogListener;
use ride\library\log\Log;

// obtain the client and generate a log session id
$client = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unknown';
$logSessionId = 'abc123';

// create a listener
$listener = new BrowseableFileLogListener('/path/to/log.file'); // make sure it's writable
$listener->setFileTruncateSize(512); // in kilobytes
$listener->setLogMessageDecorator(new LogMessageDecorator()); // formats the log messages

// create the log object
$log = new Log();

// do some logging
$log->logDebug('Debug message');
$log->logInformation('Information message', 'with a description', 'source');
$log->logWarning('Warning message', 'with a description', 'my-module');
$log->logError('Debug message', 'with a description');
$log->logException(new Exception('A exception'));

// browse the log
$logSessions = $listener->getLogSessions(array('limit' => 10, 'page' => 2), $pages);
$logSession = $listener->getLogSession($logSessionId);
$logMessages = $logSession->getLogMessages();
$logMessages = $logSession->getLogMessagesBySource('my-module');
$logMessages = $logSession->getLogMessagesByQuery('message');


You can use Composer to install this library.

composer require ride/lib-log