2017 © Pedro Peláez
 

library zf3-psr3-logger

PSR3 Logger for ZF3 and ZF2 Application

image

aqilix/zf3-psr3-logger

PSR3 Logger for ZF3 and ZF2 Application

  • Wednesday, August 16, 2017
  • by dollyaswin
  • Repository
  • 2 Watchers
  • 0 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

PSR3 Logger For ZF3 and ZF2 Application

This is a simple module for loading logger using PSR3 to your ZF3/ZF2 application. By default the logger will write to a file (data/log/system.log). But you can override the logger configuration by override logger in autoload/*.local.php. By using this module you don't need to write delegators to modify the logger from Zend\Log., (*1)

Installation

Add zf3-psr3-logger to composer.json, (*2)

composer require aqilix/zf3-psr3-logger

Add Aqilix\\ZF3PSR3Logger to config/modules.config.php, (*3)

Usage

Inject psr3_logger service into class that wanna use logger. If using factories we can do it like this, (*4)

public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
    $example = new Example();
    $example->setLogger($container->get("psr3_logger"));
    return $example;
}

And here the Example class, (*5)

class Example
{
    use Psr\Log\LoggerAwareTrait;

    public function test()
    {
        $this->logger->log(\Psr\Log\LogLevel::INFO, "{function} Testing logger", ["function" => __FUNCTION__]);
        $this->logger->log(\Psr\Log\LogLevel::ERROR, "{function} Testing logger", ["function" => __FUNCTION__]);
    }
}

The Versions