PHP code example of simpliste / log

1. Go to this page and download the library: Download simpliste/log 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/ */

    

simpliste / log example snippets




use Monolog\Handler\Handler\StreamHandler;
use Monolog\Logger;
use Simpliste\Log\LoggerAwareTrait;
use Simpliste\Log\LoggerAwareInterface;

class Whoops implements LoggerAwareInterface
{
    use LoggerAwareTrait;
    
    public function run()
    {
        $this->getLogger()->info('Started running');
    }
}

echo 'Example without a logger set';
$whoops = new Whoops();
$whoops->run();

$logger = new Logger();
$logger->pushHandler(new StreamHandler('php://stdout', Logger::INFO));

echo 'Example with a logger set';
$whoopsWithLogger = new Whoops();
$whoopsWithLogger->setLogger($logger);