예제 #1
0
 function __construct($config)
 {
     if (isset($config['display']) and $config['display'] == false) {
         $this->display = false;
     }
     parent::__construct($config);
 }
예제 #2
0
 function __construct($config)
 {
     if (isset($config['logput'])) {
         $this->logput = $config['logput'];
     }
     if (isset($config['type'])) {
         $this->type = $this->put_type[$config['type']];
     }
     parent::__construct($config);
 }
예제 #3
0
 function __construct($config)
 {
     if (empty($config['table'])) {
         throw new \Exception(__CLASS__ . ": require \$config['table']");
     }
     $this->table = $config['table'];
     if (isset($config['db'])) {
         $this->db = \Swoole::$php->db($config['db']);
     } else {
         $this->db = \Swoole::$php->db('master');
     }
     parent::__construct($config);
 }
예제 #4
0
 function __construct($config)
 {
     if (is_string($config)) {
         $file = $config;
         $config = array('file' => $file);
     }
     $this->cut_file = isset($config["cut_file"]) && $config["cut_file"] == true;
     $this->archive = isset($config['date']) && $config['date'] == true;
     $this->verbose = isset($config['verbose']) && $config['verbose'] == true;
     $this->enable_cache = isset($config['enable_cache']) ? (bool) $config['enable_cache'] : true;
     if (isset($config['level'])) {
         $this->log_line = (int) $config['level'];
     }
     //按日期存储日志
     if ($this->archive) {
         if (isset($config['dir'])) {
             $this->date = date('Ymd');
             $this->log_dir = rtrim($config['dir'], '/');
             $this->log_file = $this->log_dir . '/' . $this->date . '.log';
         } else {
             throw new \Exception(__CLASS__ . ": require \$config['dir']");
         }
     } else {
         if (isset($config['file'])) {
             $this->log_file = $config['file'];
         } else {
             throw new \Exception(__CLASS__ . ": require \$config[file]");
         }
     }
     //自动创建目录
     $dir = dirname($this->log_file);
     if (file_exists($dir)) {
         if (!is_writeable($dir) && !chmod($dir, 0777)) {
             throw new \Exception(__CLASS__ . ": {$dir} unwriteable.");
         }
     } elseif (mkdir($dir, 0777, true) === false) {
         throw new \Exception(__CLASS__ . ": mkdir dir {$dir} fail.");
     }
     $this->fp = $this->openFile($this->log_file);
     parent::__construct($config);
 }
예제 #5
0
 function __construct($config)
 {
     if (is_string($config)) {
         $file = $config;
         $config = array('file' => $file);
     }
     $this->archive = isset($config['date']) && $config['date'] == true;
     $this->enable_cache = isset($config['enable_cache']) ? (bool) $config['enable_cache'] : true;
     //按日期存储日志
     if ($this->archive) {
         if (isset($config['dir'])) {
             $this->date = date('Ymd');
             $this->log_dir = rtrim($config['dir'], '/');
             $this->log_file = $this->log_dir . '/' . $this->date . '.log';
         } else {
             throw new \Exception(__CLASS__ . ": require \$config['dir']");
         }
     } else {
         if (isset($config['file'])) {
             $this->log_file = $config['file'];
         } else {
             throw new \Exception(__CLASS__ . ": require \$config[file]");
         }
     }
     //自动创建目录
     $dir = dirname($this->log_file);
     if (file_exists($dir)) {
         if (!is_writeable($dir) && !chmod($dir, 0755)) {
             throw new \Exception(__CLASS__ . ": {$dir} unwriteable.");
         }
     } elseif (mkdir($dir, 0755, true) === false) {
         throw new \Exception(__CLASS__ . ": mkdir dir {$dir} fail.");
     }
     $this->fp = fopen($this->log_file, 'a+');
     if (!$this->fp) {
         throw new \Exception(__CLASS__ . ": can not open log_file[{$this->log_file}].");
     }
     parent::__construct($config);
 }