PHP code example of uzulla / slog

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

    

uzulla / slog example snippets



$app_log = new \Monolog\Logger('APP');
$app_log->pushHandler(new \Monolog\Handler\StreamHandler(__DIR__.'app.log', \Monolog\Logger::DEBUG));
\Uzulla\SLog::setLogger('APP', $app_log);


use \Uzulla\SLog as L;

// any location

$logger = L::getLogger('APP'); 
$logger->debug('debug me!!');
//or
L::getLogger('APP')->info("log!", ['why'=>'kantanbenri']); 


// any setup.
\Uzulla\SLog::debug('uhoh!!'); // ok!



$app_log = new \Uzulla\SLog\SimpleLogger(); // about SimpleLogger, see under.
\Uzulla\SLog::setLogger('_', $app_log);

//...

L::getLogger('_')->info("uhoh!");


use \Uzulla\SLog\SimpleLogger;

// out put to error_log(), log level DEBUG.
$log = new SimpleLogger();
// or
// out put to error_log(), log level NOTICE
$log = new SimpleLogger(SimpleLogger::NOTICE);
// or
// out put to 'test.log', log level WARNING
$log = new SimpleLogger(SimpleLogger::WARNING, __DIR__.'/test.log');

// ...

$log->alert('ALERT!!!');