1. Go to this page and download the library: Download alexya-framework/logger 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/ */
alexya-framework / logger example snippets
namespace Test;
use \Alexya\Logger\AbstractLogger;
/**
* Simple logger that echoes each log entry
*/
class Logger extends AbstractLogger
{
protected function _write($message, $placeholders)
{
echo $message;
}
}
$Logger = new \Alexya\Logger\File(
new \Alexya\FileSystem\Direcctory("/tmp/log/Alexya"),
"{YEAR}-{MONTH}-{DAY}.log",
"[{HOUR}:{MINUTE}] ({LEVEL}) {LOG}",
[
\Psr\Log\LogLevel::EMERGENCY,
\Psr\Log\LogLevel::ALERT,
\Psr\Log\LogLevel::CRITICAL,
\Psr\Log\LogLevel::ERROR,
\Psr\Log\LogLevel::WARNING,
\Psr\Log\LogLevel::NOTICE,
\Psr\Log\LogLevel::INFO,
\Psr\Log\LogLevel::DEBUG
]
);
$Logger->debug("test"); // [00:00] (debug) test
$Logger->info("[{HOUR}:{MINUTE}] ({LEVEL}) {CUSTOM_PLACEHOLDER}", [
"CUSTOM_PLACEHOLDER" => "test"
]); // [00:00] (debug) test