= self::cur_level && $lev <= self::RUN) { $level = self::get_level($lev); $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '.log'; $content = "[{$now}] {$level}: {$message}\r\n"; file_put_contents($log_file, $content, FILE_APPEND); } if($lev == self::ERR) { self::msg(); } } public static function endl($lev = self::ERR) { $content = "\r\n"; if($lev == self::SQL && self::open_sql) { $log_file = BASE_DATA_PATH.'/log/'.date('Ymd',time()).'-sql.log'; file_put_contents($log_file,$content, FILE_APPEND); return; } if($lev >= self::cur_level) { $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '.log'; file_put_contents($log_file, $content, FILE_APPEND); } } public static function msg() { $debugInfo = debug_backtrace(); $stack = "["; foreach($debugInfo as $key => $val){ if(array_key_exists("file", $val)){ $stack .= ",file:" . $val["file"]; } if(array_key_exists("line", $val)){ $stack .= ",line:" . $val["line"]; } if(array_key_exists("function", $val)){ $stack .= ",function:" . $val["function"]; } } $stack .= "]"; return $stack; } private static function get_level($lev) { if($lev == self::INFO) return 'INFO'; if($lev == self::DEBUG) return 'DEBUG'; if($lev == self::WARING) return 'WARING'; if($lev == self::ERR) return 'ERR'; if($lev == self::RUN) return 'RUN'; return 'Unknown'; } public static function read() { return self::$log; } }