2017 © Pedro Peláez
 

library lib-log

Log library of the Ride framework

image

ride/lib-log

Log library of the Ride framework

  • Thursday, March 9, 2017
  • by ride-user
  • Repository
  • 7 Watchers
  • 0 Stars
  • 12,193 Installations
  • PHP
  • 22 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 4 % Grown

The README.md

Ride: Log Library

Log library of the PHP Ride framework., (*1)

Logging is used to keep an history of events or to debug an application., (*2)

What's In This Library

LogMessage

A log message defines what's being done or what happened., (*3)

It consists a:, (*4)

  • 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)

LogSession

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

Log

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., (*6)

LogListener

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., (*7)

BrowseableLogListener

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., (*8)

Code Sample

Check this code sample to see the possibilities of this library:, (*9)

<?php

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();
$log->setId($logSessionId);
$log->setClient($client);
$log->addLogListener($listener);

// 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');

Installation

You can use Composer to install this library., (*10)

composer require ride/lib-log

The Versions

09/03 2017

dev-master

9999999-dev

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

09/03 2017

dev-develop

dev-develop

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

09/03 2017

1.0.3

1.0.3.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

08/09 2016

1.0.2

1.0.2.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

24/08 2016

1.0.1

1.0.1.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

17/08 2016

1.0.0

1.0.0.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

20/01 2016

0.4.0

0.4.0.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

09/09 2015

0.3.2

0.3.2.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

01/04 2015

0.3.1

0.3.1.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

27/03 2015

0.3.0

0.3.0.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

04/05 2014

0.2.2

0.2.2.0

Log library of the Ride framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

14/10 2013

0.2.1

0.2.1.0

Log library of the Pallo framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

28/09 2013

0.2.0

0.2.0.0

Log library of the Pallo framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

22/09 2013

0.1.0

0.1.0.0

Log library of the Pallo framework

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd