PHP code example of elementary / logger-pool
1. Go to this page and download the library: Download elementary/logger-pool library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
elementary / logger-pool example snippets
use elementary\logger\pool\LoggerPool;
use elementary\logger\traits\LoggerGetInterface;
use elementary\logger\traits\LoggerTrait;
use elementary\logger\graylog\udp\GraylogUdp;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\NullLogger;
class Example implements LoggerGetInterface, LoggerAwareInterface
{
use LoggerTrait;
public function doSomeThing()
{
// Do some thing
$this->getLogger()->debug('do some thing');
// Runtime error should be logged and monitored
$this->getLogger()->error('Attantion! The error was happened!');
}
}
LoggerPool::me()->setLogger(new NullLogger());
LoggerPool::me()->setLogger(new GraylogUdp('test', 'localhost', 12201), 'warning');
$ex = new Example();
$ex->setLogger(LoggerPool::me());
$ex->doSomeThing();