使用SeasLog打造PHP项目中的高性能日志组件(1)(2)
默认常量有哪些
遵循PSR-3标准,SeasLog 共将日志分成8个级别
●SEASLOG_DEBUG "debug"
●SEASLOG_INFO "info"
●SEASLOG_NOTICE "notice"
●SEASLOG_WARNING "warning"
●SEASLOG_ERROR "error"
●SEASLOG_CRITICAL "critical"
●SEASLOG_ALERT "alert"
●SEASLOG_EMERGENCY "emergency"
都提供哪些方法
SeasLog 提供了这样一组函数,可以方便地获取与设置根目录、模块目录、快速写入与统计log。 相信从下述伪代码的注释中,您可以快速获取函数信息(有经验的coder,也可将下述代码保存成SeasLog.php导入你的IDE,code tips,你懂的),具体使用将紧接其后:
- <?php
- /**
- * @author neeke@php.net 云智慧
- */
- class SeasLog
- {
- public function __construct()
- {
- #SeasLog init
- }
- public function __destruct()
- {
- #SeasLog distroy
- }
- /**
- * 设置basePath
- * @param $basePath
- * @return bool
- */
- static public function setBasePath($basePath)
- {
- return TRUE;
- }
- /**
- * 获取basePath
- * @return string
- */
- static public function getBasePath()
- {
- return 'the base_path';
- }
- /**
- * 设置模块目录
- * @param $module
- * @return bool
- */
- static public function setLogger($module)
- {
- return TRUE;
- }
- /**
- * 获取最后一次设置的模块目录
- * @return string
- */
- static public function getLastLogger()
- {
- return 'the lastLogger';
- }
- /**
- * 统计所有类型或单个类型)行数
- * @param string $level
- * @param string $log_path
- * @param null $key_word
- * @return array | long
- */
- static public function analyzerCount($level = 'all',$log_path = '*',$key_word = NULL)
- {
- return array();
- }
- /**
- * 以数组形式,快速取出某类型log的各行详情
- * @param $level
- * @param string $log_path
- * @param null $key_word
- * @param int $start
- * @param int $limit
- * @return array
- */
- static public function analyzerDetail($level = SEASLOG_INFO,$log_path = '*',$key_word = NULL, $start = 1,$limit = 20)
- {
- return array();
- }
- /**
- * 获得当前日志buffer中的内容
- * @return array
- */
- static public function getBuffer()
- {
- return array();
- }
- /**
- * 记录debug日志
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function debug($message,array $content = array(),$module = '')
- {
- #$level = SEASLOG_DEBUG
- }
- /**
- * 记录info日志
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function info($message,array $content = array(),$module = '')
- {
- #$level = SEASLOG_INFO
- }
- /**
- * 记录notice日志
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function notice($message,array $content = array(),$module = '')
- {
- #$level = SEASLOG_NOTICE
- }
- /**
- * 记录warning日志
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function warning($message,array $content = array(),$module = '')
- {
- #$level = SEASLOG_WARNING
- }
- /**
- * 记录error日志
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function error($message,array $content = array(),$module = '')
- {
- #$level = SEASLOG_ERROR
- }
- /**
- * 记录critical日志
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function critical($message,array $content = array(),$module = '')
- {
- #$level = SEASLOG_CRITICAL
- }
- /**
- * 记录alert日志
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function alert($message,array $content = array(),$module = '')
- {
- #$level = SEASLOG_ALERT
- }
- /**
- * 记录emergency日志
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function emergency($message,array $content = array(),$module = '')
- {
- #$level = SEASLOG_EMERGENCY
- }
- /**
- * 通用日志方法
- * @param $level
- * @param $message
- * @param array $content
- * @param string $module
- */
- static public function log($level,$message,array $content = array(),$module = '')
- {
- }
- }
评论暂时关闭