2017 © Pedro Peláez
 

library zend-psr-logger

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

image

seyfer/zend-psr-logger

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

  • Sunday, February 11, 2018
  • by seyfer
  • Repository
  • 2 Watchers
  • 4 Stars
  • 968 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

ZendPsrLogger

This is module that implement PSR-3 log interface with Zend\log component. Also implement Doctrine log writer., (*1)

Installation

Get from packagist or github., (*2)

require "seyfer/zend-psr-logger": "dev-master", (*3)

http://modules.zendframework.com/seyfer/ZendPsrLogger, (*4)

If using Zend2, than enable in application.config.php, add 'ZendPsrLogger' to modules., (*5)

Configuration

Extra column mapping and Entity name in module.config.php. Extra column ipaddress for example., (*6)

'logger'        => array(
        'registeredLoggers' => array(
            'DefaultLogger' => array(
                'entityClassName' => '\ZendPsrLogger\Entity\DefaultLog',
                'columnMap'       => array(
                    'timestamp'    => 'timestamp',
                    'priority'     => 'priority',
                    'priorityName' => 'priorityName',
                    'message'      => 'message',
                    'extra'        => array(
                        'ipaddress' => 'ipaddress',
                    ),
                )
            ),
            'ElseDefaultLogger' => array(
                'entityClassName' => '\ZendPsrLogger\Entity\ElseDefaultLog',
                'columnMap'       => array(
                    'timestamp'    => 'timestamp',
                    'priority'     => 'priority',
                    'priorityName' => 'priorityName',
                    'message'      => 'message',
                    'extra'        => array(
                        'fileName' => 'fileName',
                    ),
                )
            )
        ),
    ),

Than set abstract factory with your module logger custom name in Module.php, (*7)

public function getServiceConfig()
    {
        return array(
            'abstract_factories' => array(
                'DefaultLogger' => '\ZendPsrLogger\Service\AbstractLoggerFactory',
                'ElseDefaultLogger' => '\ZendPsrLogger\Service\AbstractLoggerFactory',
            ),
        );
    }

Factory will use your module.config.php logger config. You can implement your factory and using writers, that implement Zend\Log\Writer\AbstractWriter., (*8)

To implement your Doctrine log entity you can extend it from Logger\Entity\BaseLog and just add your extra column mapping., (*9)

<?php

namespace MyModule\Entity\Log;

use Doctrine\ORM\Mapping as ORM;
use Logger\Entity\BaseLog;

/**
 * @ORM\Entity
 * @ORM\Table(name="parser_log")
 */
class MyModuleLog extends BaseLog
{

    /**
     * @var string
     * @ORM\Column(type="string", name="file_name", nullable=true)
     */
    protected $fileName;

}

And than register your logger in your Module and add config like in example., (*10)

Usage

First init logger, (*11)

use ZendPsrLogger\LoggerInterface;
use ZendPsrLogger\NullLogger;
...

/** @var type LoggerInterface */
$this->logger
...

if ($this->getServiceLocator()->has($myLoggerName)) {
    $logger = $this->getServiceLocator()->get($myLoggerName);
} else {
    $logger = new NullLogger();
}

$this->logger = $logger;

Than use it's level function, (*12)

$this->logger->addExtra(['ipaddress' => '11.22.33.44']);
$this->logger->debug("test");

Or log directly using \Psr\Log\LogLevel constants for level parameter., (*13)

$this->logger->log(\Psr\Log\LogLevel::DEBUG, "test", ['ipaddress' => '11.22.33.44']);

License

GPL. If you want implement more writers or other improvements - you're welcome!, (*14)

Change Log

v1.1.0 - use AbstractLoggerFactory and new config structure for multiple logger creation, (*15)

v1.0.1 - implement Doctrine writer - use LoggerFactory for logger creation, (*16)

The Versions

11/02 2018

dev-master

9999999-dev http://seyferseed.ru

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

  Sources   Download

GPL v2 GPL-3.0-or-later

The Requires

 

11/02 2018

v1.1.2

1.1.2.0 http://seyferseed.ru

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

  Sources   Download

GPL-3.0-or-later

The Requires

 

01/06 2015

v1.1.1

1.1.1.0 http://seyferseed.ru

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

  Sources   Download

GPL v2

The Requires

 

02/07 2014

v1.1.0

1.1.0.0 http://seyferseed.ru

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

  Sources   Download

GPL v2

The Requires

 

26/06 2014

v1.0.2

1.0.2.0 http://seyferseed.ru

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

  Sources   Download

GPL v2

The Requires

 

23/06 2014

v1.0.1

1.0.1.0 http://seyferseed.ru

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

  Sources   Download

GPL v2

The Requires

 

20/06 2014

v1.0.0

1.0.0.0 http://seyferseed.ru

Base module for custom loggers. This is module that implement PSR-3 log interface with use Zend\Log component. Also implement Doctrine log writer.

  Sources   Download

GPL v2

The Requires