PHP code example of arrilot / logs
1. Go to this page and download the library: Download arrilot/logs 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/ */
arrilot / logs example snippets
use Arrilot\Logs\Logs;
class Foo
{
use Logs;
function bar()
{
$this->logger()->error('Error happened in bar!);
$this->logger()->warning('Warning happened in bar!);
// etc
}
}
$foo = new Foo();
$foo->bar(); // Everything is ok, but nothing was logged anywhere because no logger was set.
$foo->setLogger($anyPsr3LoggerHere);
$foo->bar(); // There is a log record in $anyPsr3LoggerHere now.
$foo->setEchoLogger();
$foo->bar(); // An error and a warning are echo'ed to a screen.
// If you are using Monolog\Registry to store loggers, you can simply pass a logger name and the package will grab a logger from the Registry.
$foo->setLogger('application_log');
$foo->bar(); // There is a record in application log.