handle with array/config/log/guzzle etc.
A application logger can extends XiaoYun\Supports\Log
and modify createLogger
method, the method must return instance of Monolog\Logger
.
use XiaoYun\Supports\Log;
use Monolog\Logger;
class APPLICATIONLOG extends Log
{
/**
* Make a default log instance.
*
* @author XiaoYun <[email protected]>
*
* @return Logger
*/
public static function createLogger()
{
$handler = new StreamHandler('./log.log');
$handler->setFormatter(new LineFormatter("%datetime% > %level_name% > %message% %context% %extra%\n\n"));
$logger = new Logger('XiaoYun.private_number');
$logger->pushHandler($handler);
return $logger;
}
}
Or, just init the log service with:
use XiaoYun\Supports\Log;
protected function registerLog()
{
$logger = Log::createLogger($file, $identify, $level);
Log::setLogger($logger);
}
After registerLog, you can use Log service:
use XiaoYun\Supports\Log;
Log::debug('test', ['test log']);