<?php
/**
* Description:记录日志处理类
* User: lijun
* Date: 2017/6/7
* Time: 11:30
*/
namespace App\Utils;
use Illuminate\Log\Writer;
use Monolog\Logger;
class BLogger
{
// 所有的LOG都要求在这里注册
const LOG_DEBUG = 'debug';
const LOG_INFO = 'info';
const LOG_NOTICE = 'notice';
const LOG_WARNING = 'warning';
const LOG_ERROR = 'error';
const LOG_CRITICAL = 'critical';
const LOG_ALERT = 'alter';
const LOG_EMERGENCY = 'emergency';
const LOG_SQL = 'sql';
private static $loggers = array();
// 获取一个实例
public static function getLogger($type = self::LOG_DEBUG, $path = '', $day = 30)
{
if (empty(self::$loggers[$type])) {
self::$loggers[$type] = new Writer(new Logger($type));
$path = $path ? '/logs'.trim($path,'/') : '/logs';
self::$loggers[$type]->useDailyFiles(storage_path().$path.'/'. $type .'.log', $day);
}
$log = self::$loggers[$type];
return $log;
}
}