php Logs类
2016-07-15 14:11
330 查看
<?php SeasLog::setLogger('IC'); SeasLog::log('info',"test"); class Logs{ use SeasLog; public static function test() { SeasLog::log('info',111); } /** * 获取访问者的ip 请求的uri * * return 访问者的ip 请求的uri ip_address | request_uri */ public static function getIpUri() { return $_SERVER['REMOTE_ADDR'] . ' | ' ; } /** * 设置日志的根路径 * @param $basePath * * */ public static function setBasePath($basePath) { SeasLog::setBasePath($basePath); } /** *获取日志的根路径 * * retrun string * */ public static function getBasePath() { return SeasLog::getBasePath(); } /** * 设置模块目录 * @param $module * * */ public static function setLogger($module) { SeasLog::setLogger($module); } /** * 获取最后一次的设置的模块 * return string * * */ public static function getLastLogger() { return SeasLog::getLastLogger(); } /** *统计所有类型(或单个类型)行数 * @param string $level * @param string $log_path * @param null $key_word * * @return array | long * */ public static 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 * @param $order 默认为正序 SEASLOG_DETAIL_ORDER_ASC,可选倒序 SEASLOG_DETAIL_ORDER_DESC * * @return array */ public static function analyzerDetail($level = SEASLOG_INFO, $log_path = '*', $key_word = NULL, $start = 1, $limit = 20, $order = SEASLOG_DETAIL_ORDER_ASC){ return SeasLog::analyzerDetail($level = SEASLOG_INFO, $log_path = '*', $key_word = NULL, $start = 1, $limit = 20, $order = SEASLOG_DETAIL_ORDER_ASC); } /** * 获取当前日志的Buffer的内容 * return array * */ public static function getBuffer() { return getBuffer(); } /** * 将buffer中的日志立刻刷到硬盘 * * @return bool */ public static function flushBuffer(){ return true; } /** * 记录debug日志 * @param $message * @param array $content * @param string $module */ public static function debug($message,array $content = array(),$module = ''){ #$level = SEASLOG_DEBUG $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::debug($message,$content,$module); } /** * 记录info日志 * @param $message * @param array $content * @param string $module * * */ public static function info($message,array $content = array(),$module = '') { #$level = SEASLOG_INFO $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::info($message,$content,$module); } /** * 记录notice日志 * @param $message * @param array $content * @param string $module * * */ public static function notice($message,array $content = array(),$module = '') { #$level = SEASLOG_NOTICE $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::notice($message,$content,$module); } /** * 记录warning日志 * @param $message * @param array $content * @param string $module * */ public static function warning($message,array $content = array(),$module = '') { #$level = SEASLOG_WARNING $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::warning($message,$content,$module); } /** * 记录error日志 * @param $message * @param array $content * @param string $module */ public static function error($message,array $content = array(),$module = '') { #$level = SEASLOG_ERROR $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::error($message,$content,$module); } /** * 记录critical日志 * @param $message * @param array $content * @param string $module */ public static function critical($message,array $content = array(),$module = '') { #$level = SEASLOG_CRITICAL $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::critical($message,$content,$module); } /** * 记录alert日志 * @param $message * @param array $content * @param string $module */ public static function alert($message,array $content = array(),$module = '') { #$level = SEASLOG_ALERT $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::alert($message,$content,$module); } /** * 记录emergency日志 * @param $message * @param array $content * @param string $module */ public static function emergency($message,array $content = array(),$module = '') { #$level = SEASLOG_EMERGENCY $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::emergency($message,$content,$module); } /** * 通用日志方法 * @param $level * @param $message * @param array $content * @param string $module */ public static function log($level,$message,array $content = array(),$module = '') { $message = self::getIpUri().$message; if($module !== ''){ $module = $_SERVER['SERVER_NAME'].'/'.$module; } SeasLog::log($level,$message,$content,$module); } } ?>
相关文章推荐
- laravel excel安装使用,导入(读)导出(数据写入文件)
- 新浪微博LAMP性能优化之路 - PHP性能优化
- 【译】PHP中的Session及其一些安全措施
- 自定义PHP页面跳转函数redirect($url, $time = 0, $msg = '')
- NULL和空是两个概念的原因
- htpasswd 详解
- php中return exit() die()的区别
- php访问url的四种方式
- PHP类的属性不能被赋值为变量的原因
- php面向对象中this,self,parent三个关键字的含义
- ntp服务
- php中echo() print() print-r()区别
- php中return和exit的区别
- php中时间戳和日期格式的转换
- php为什么不能用empty($_POST)来判断是否有传值
- PHP进程及进程间通信
- php中curl_multi函数集的用法
- laravel: command not found问题解决方案
- phpexcel的使用方法详细介绍
- 利用PHP的debug_backtrace函数,实现PHP文件权限管理、动态加载