2017 © Pedro Peláez
 

library phossa-logger

The PSR-3 compliant PHP logging library.

image

phossa/phossa-logger

The PSR-3 compliant PHP logging library.

  • Sunday, June 12, 2016
  • by phossa
  • Repository
  • 1 Watchers
  • 1 Stars
  • 167 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

phossa-logger [ABANDONED]

Build Status Latest Stable Version License, (*1)

See new lib at phoole/logger, (*2)

Introduction

Phossa-logger is a PSR-3 compliant logging library. It is a rewrite of Monolog with lots of changes., (*3)

More information about PSR-3, (*4)

Installation

Install via the composer utility., (*5)

composer require "phossa/phossa-logger=1.*"

or add the following lines to your composer.json, (*6)

{
    "require": {
       "phossa/phossa-logger": "^1.0.5"
    }
}

Usage

  • Simple usage, (*7)

    // logger with id 'mylogger'
    $logger = new \Phossa\Logger\Logger('mylogger');
    
    // a notice
    $logger->notice('a notice from code');
    
    // a warning
    $logger->warning('a warning from code');
    

Features

  • Decorator: used to modify the $logEntry in some way., (*8)

    • Implements the __invoke() method, makes decorator a callable
    class InterpolateDecorator extends DecoratorAbstract
    {
        public function __invoke(LogEntryInterface $log)
        {
            // ...
        }
    }
    
    • User-defined functions can also be used as decorator
    $logger->setDecorators([
        new Decorator/InterpolateDecorator(),
        function ($logEntry) {
            // ...
        }
    ]);
    
    • Decorator implements DecoratorInterface can be disabled at runtime
    $inter = new Decorator/InterpolateDecorator();
    $logger->addDecorator($inter);
    // ...
    
    // disble the InterpolateDecorator at runtime
    $inter->stopDecorator();
    
  • Handler: distribute log entry to different devices. Multiple handlers can be set at the same time., (*9)

    // create a logger with channel 'MyLogger'
    $logger  = new Logger('MyLogger');
    
    // syslog handler with ident set to 'MyLogger'
    $syslog  = new Handler\SyslogerHandler($logger->getChannel());
    
    // console handler with output to stderr
    $console = new Handler\TerminalHandler();
    
    // add handlers
    $logger->addHandler($syslog);
    $logger->addHandler($console);
    
    // ...
    // at some point, stop console logging
    $console->stopHandler();
    
  • Formatter: turn log entry object into string. A formatter is bound to a specific handler., (*10)

    // console handler with output to stderr
    $console = new Handler\TerminalHandler();
    
    // set AnsiFormatter
    $console->setFormatter(new Formatter\AnsiFormatter());
    
  • Handler/Decorator/Formatter all enforce '__invoke()' in the their interface, which makes them callable., (*11)

  • User may use all sorts of callable as handler, decorator or formatter., (*12)

    // handler
    $syslog = new SyslogHandler();
    
    // set a anonymous function as a formatter
    $syslog->setFormatter(
      function ($log) {
          // ...
          return $string;
      }
    );
    
    // adding different handlers
    $logger->setHandlers([
      $syslog,
      function ($log) {
          // convert $log to string and send to a log device
          // ...
      }
    ]);
    
  • LogEntryInterface for log entry (or call it message). It is now possible to extend LogEntry and use a factory closure to create log entry., (*13)

    $logger = new Logger('MyLogger', [], [],
      function ($level, $message, $context) {
          return new MyLogEntry($level, $message, $context);
      }
    );
    
  • Support PHP 5.4+, PHP 7.0+, HHVM, (*14)

  • PHP7 ready for return type declarations and argument type declarations., (*15)

  • PSR-1, PSR-2, PSR-3, PSR-4 compliant., (*16)

Dependencies

  • PHP >= 5.4.0
  • phossa/phossa-shared >= 1.0.3
  • psr/log

License

MIT License, (*17)

The Versions

12/06 2016

dev-master

9999999-dev https://github.com/phossa/phossa-logger

The PSR-3 compliant PHP logging library.

  Sources   Download

MIT

The Requires

 

psr psr-3 framework logging phossa

18/04 2016

1.0.7

1.0.7.0 https://github.com/phossa/phossa-logger

The PSR-3 compliant PHP logging library.

  Sources   Download

MIT

The Requires

 

psr psr-3 framework logging phossa

18/04 2016

1.0.6

1.0.6.0 https://github.com/phossa/phossa-logger

The PSR-3 compliant PHP logging library.

  Sources   Download

MIT

The Requires

 

psr psr-3 framework logging phossa

03/02 2016

1.0.5

1.0.5.0 https://github.com/phossa/phossa-logger

The PSR-3 compliant PHP logging system.

  Sources   Download

MIT

The Requires

 

psr psr-3 framework logging phossa

03/02 2016

1.0.4

1.0.4.0 https://github.com/phossa/phossa-logger

The PSR-3 compliant PHP logging system.

  Sources   Download

MIT

The Requires

 

psr psr-3 framework logging phossa

01/02 2016

1.0.3

1.0.3.0 https://github.com/phossa/phossa-logger

The PSR-3 compliant PHP logging system.

  Sources   Download

MIT

The Requires

 

psr psr-3 framework logging phossa

26/01 2016

1.0.2

1.0.2.0 https://github.com/phossa/phossa-logger

The PSR-3 compliant PHP logging system.

  Sources   Download

MIT

The Requires

 

psr psr-3 framework logging phossa

25/01 2016

1.0.1

1.0.1.0 https://github.com/phossa/phossa-logger

The PSR-3 compliant PHP logging system.

  Sources   Download

MIT

The Requires

 

psr psr-3 framework logging phossa

02/11 2015

1.0.0

1.0.0.0 https://github.com/phossa/phossa-logger

The logging package of Phossa framework

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • phossa-shared >=1.0.0
  • psr/logger *

 

framework logging phossa