2017 © Pedro Peláez
 

library yolk-log

Gamer Network's PHP logging component

image

gamernetwork/yolk-log

Gamer Network's PHP logging component

  • Wednesday, May 18, 2016
  • by gamer-network
  • Repository
  • 9 Watchers
  • 0 Stars
  • 5,000 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

Yolk Logger

Scrutinizer Code Quality, (*1)

A simple PSR-3 logging library. Currently supports output to the standard PHP error log, files, stdout, stderr and syslog., (*2)

Requirements

This library requires PHP 5.4 or later, the Yolk Contracts package (gamernetwork/yolk-contracts) and the PSR-3 reference logger (psr/log)., (*3)

Installation

It is installable and autoloadable via Composer as gamer-network/yolk-logger., (*4)

Alternatively, download a release or clone this repository, and add the \yolk\log and \Psr\Log namespaces to an autoloader., (*5)

License

Yolk Logger is open-sourced software licensed under the MIT license, (*6)

Quick Start

use yolk\log\LogLevel;

// create a factory
$f = new LoggerFactory();

// create some simple logs with default threshold (INFO)
$l = $f->create('php');
$l = $f->create('stderr');
$l = $f->create('stdout');
$l = $f->create('null');

// specify configuration options
$l = $f->create([
    'type' => 'file'
    'file' => '/var/log/php/myapp.log'
]);

$l = $f->create([
    'type'   => 'syslog'
    'prefix' => 'myapp'
]);

// specify a threshold
$l = $f->create([
    'type'      => 'stderr',
    'threshold' => LogLevel::INFO,
]);

// simple message
$l->warning('Ooops! Something went wrong');

// message with context
$l->info(
    "{user} logged in at {time}",
    [
        'user' => 'Gary',
        'time' => '2014-10-02 12:34:56',
    ]
);

Using as part of yolk Services

In your config file, put something like this:, (*7)

$config['logs'] = array(
    // log using error_log for cli-server
    'log' => array( 'type' => 'syslog', 'threshold' => yolk\log\LogLevel::WARN ),
    'audit' => array( 'type' => 'file', 'file' => '/var/log/audit.log', 'threshold' => yolk\log\LogLevel::INFO )
);

...and use with:, (*8)

$this->services["log.log"]->debug( "Dispatching for: '" . $request->uri() . "'");
$this->services["log.audit"]->info( "So and so did something or other");

If you're working with php cli-server, STDOUT and STDERR not available, but try this:, (*9)

$config['logs'] = array(
    // log using error_log for cli-server
    'log' => array( 'type' => 'php', 'threshold' => yolk\log\LogLevel::DEBUG )
);

The Versions

18/05 2016

dev-develop

dev-develop

Gamer Network's PHP logging component

  Sources   Download

MIT

The Requires

 

The Development Requires

logger logging eurogamer gamer network

24/07 2015

dev-master

9999999-dev

Gamer Network's PHP logging component

  Sources   Download

MIT

The Requires

 

The Development Requires

logger logging eurogamer gamer network

24/07 2015

v1.0

1.0.0.0

Gamer Network's PHP logging component

  Sources   Download

MIT

The Requires

 

The Development Requires

logger logging eurogamer gamer network