A simple and lightful logger for PHP
一个简洁的、轻量级的PHP日志工具
composer require blogdaren/logger
- packagist: blogdaren/custom-terminal-color
<?php
require_once dirname(__FILE__) . '/vendor/autoload.php';
use Logger\Logger;
while(1)
{
usleep(500000);
Logger::info('with INFO level');
Logger::debug('with DEBUG level');
Logger::warn('with WARNING level');
Logger::error('with ERROR level');
Logger::crazy('with CRAZY level');
}
1、Available Method:
Logger::show($arg1, $arg2, $arg3, $arg4);
Logger::info($arg1, $arg3, $arg4);
Logger::debug($arg1, $arg3, $arg4);
Logger::warn($arg1, $arg3, $arg4);
Logger::error($arg1, $arg3, $arg4);
Logger::crazy($arg1, $arg3, $arg4);
Logger::disableLogShowWithLevel(['info', 'error']);
Logger::enableLogShowWithLevel(['info', 'error']);
Logger::setLogFile('/tmp/demo.log');
Logger::setDebugMode(true);
2、The method listed above share the same arguments:
* $arg1: message to be logged
* $arg2: log level with 5 options:
>> Logger::LOG_LEVEL_INFO
>> Logger::LOG_LEVEL_DEBUG
>> Logger::LOG_LEVEL_WARN
>> Logger::LOG_LEVEL_ERROR
>> Logger::LOG_LEVEL_CRAZY
* $arg3: determine whether to print log or not, default `NULL`.
* $arg4: where to store log file, default `''`, u can keep it empty then will do nothing.