PHP code example of gamernetwork / yolk-log
1. Go to this page and download the library: Download gamernetwork/yolk-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/ */
gamernetwork / yolk-log example snippets
use yolk\log\LogLevel;
// create a factory
$f = new LoggerFactory();
// create some simple logs with default threshold (INFO)
$l = $f->create('php');
$l = $f->create('stderr');
$l = $f->create('stdout');
$l = $f->create('null');
// specify configuration options
$l = $f->create([
'type' => 'file'
'file' => '/var/log/php/myapp.log'
]);
$l = $f->create([
'type' => 'syslog'
'prefix' => 'myapp'
]);
// specify a threshold
$l = $f->create([
'type' => 'stderr',
'threshold' => LogLevel::INFO,
]);
// simple message
$l->warning('Ooops! Something went wrong');
// message with context
$l->info(
"{user} logged in at {time}",
[
'user' => 'Gary',
'time' => '2014-10-02 12:34:56',
]
);