Example #1
0
 public static function alarm($config = [])
 {
     $type = isset($config['type']) ? $config['type'] : 'Email';
     $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\alarm\\') . ucwords($type);
     unset($config['type']);
     self::$alarm = new $class($config['alarm']);
 }
Example #2
0
 public static function alarm($config = [])
 {
     $type = isset($config['type']) ? $config['type'] : 'Email';
     $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\alarm\\') . ucwords($type);
     unset($config['type']);
     self::$alarm = new $class($config['alarm']);
     // 记录初始化信息
     APP_DEBUG && Log::record('[ CACHE ] ALARM ' . $type . ': ' . var_export($config, true), 'info');
 }
Example #3
0
 /**
  * 日志保存
  * @access public
  * @param string $destination  写入目标
  * @param string $level 保存的日志级别
  * @return void
  */
 public static function save($destination = '', $level = '')
 {
     $log = self::getLog($level);
     if (empty($log)) {
         return;
     }
     $message = '';
     if ($level) {
         $message .= implode("\r\n", $log);
         self::$log[$level] = [];
     } else {
         foreach ($log as $info) {
             $message .= implode("\r\n", $info) . "\r\n";
         }
         self::$log = [];
     }
     self::$storage && self::$storage->write($message, $destination);
 }
Example #4
0
 /**
  * 保存调试信息
  * @return bool
  */
 public static function save()
 {
     if (!empty(self::$log)) {
         if (is_null(self::$driver)) {
             self::init(Config::get('log'));
         }
         $result = self::$driver->save(self::$log);
         if ($result) {
             self::$log = [];
         }
         return $result;
     }
     return true;
 }
Example #5
0
File: Log.php Project: GDdark/cici
 /**
  * 保存调试信息
  * @return bool
  */
 public static function save()
 {
     if (!empty(self::$log)) {
         if (is_null(self::$driver)) {
             self::init(Config::get('log'));
         }
         if (!self::check(self::$config)) {
             // 检测日志写入权限
             return false;
         }
         if (empty(self::$config['level'])) {
             // 获取全部日志
             $log = self::$log;
         } else {
             // 记录允许级别
             $log = [];
             foreach (self::$config['level'] as $level) {
                 if (isset(self::$log[$level])) {
                     $log[$level] = self::$log[$level];
                 }
             }
         }
         $result = self::$driver->save($log);
         if ($result) {
             self::$log = [];
         }
         return $result;
     }
     return true;
 }
Example #6
0
 /**
  * 清空日志信息
  * @return void
  */
 public static function clear()
 {
     self::$log = [];
 }