1. Go to this page and download the library: Download webiik/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/ */
webiik / log example snippets
$log = new \Webiik\Log\Log();
$log->addLogger(function () {
return new \Webiik\Log\Logger\FileLogger();
});
$log->info('Hello {name}!', ['name' => 'Dolly!']);
$log->write();
addLogger(callable $factory): Logger
$log->addLogger(function () {
return new \Webiik\Log\Logger\ErrorLogger();
});
// CustomLogger.php
declare(strict_types=1);
use Webiik\Log\Message;
class CustomLogger implements Webiik\Log\Logger\LoggerInterface
{
public function write(Message $message): void
{
// Process Message...
}
}
// This logger logs only log messages belonging to 'error' group
$log->addLogger(function () {
return new \Webiik\Log\Logger\ErrorLogger();
})->setGroup('error');
// Add some log messages
$log->info('Some info.');
$log->warning('Some error.')->setGroup('error');
// This logger doesn't log messages belonging to 'error' group
$log->addLogger(function () {
return new \Webiik\Log\Logger\FileLogger();
})->setNegativeGroup('error');
// Add some log messages
$log->info('Some info.');
$log->warning('Some error.')->setGroup('error');
Logger->setLevel(string $level): Logger
// This logger logs messages from all groups but only with log level 'info'
$log->addLogger(function () {
return new \Webiik\Log\Logger\FileLogger();
})->setLevel('info');
setSilent(bool $silent): void
$log = setSilent(true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.