1. Go to this page and download the library: Download zozlak/logging 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/ */
zozlak / logging example snippets
// simplest possible logging
$log = new \zozlak\logging\Log('log_file');
$log->info('message');
// logging to standard out/err
$log = new \zozlak\logging\Log('php://stdout');
$log->info('message');
$log = new \zozlak\logging\Log('php://stderr');
$log->info('message');
// logging to already opened file
$logFile = tmpfile();
$log = new \zozlak\logging\Log($logFile);
$log->info('message');
// message formatting and filtering
$log = new \zozlak\logging\Log('log_file', \Psr\Log\LogLevel::INFO, "{LEVEL}:{TIMESTAMP}:{FILE}:{LINE}:{MESSAGE}");
$log->info('message');
$log->debug('skipped message');
// singleton example
$log = new \zozlak\logging\Log('log_file');
\zozlak\logging\Logger::addLog($log);
\zozlak\logging\Logger::info('message');
// singleton with multiple logs
$logAll = new \zozlak\logging\Log('log_all');
$logErrors = new \zozlak\logging\Log('log_errors', \Psr\Log\LogLevel::ERROR);
\zozlak\logging\Logger::addLog($logAll, 'all');
\zozlak\logging\Logger::addLog($logErrors, 'error');
\zozlak\logging\Logger::info('message1', [], 'all');
\zozlak\logging\Logger::error('message2', [], 'error');
\zozlak\logging\Logger::error('message3'); // written to the 'error' log
\zozlak\logging\Logger::setDefaultLog('all');
\zozlak\logging\Logger::error('message4'); // written to the 'all' log
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.