Git Product home page Git Product logo

php-yklogger's Introduction

php- YkLogger

php日志记录扩展. 共有5种级别. 分为: debug, info(trace), warn, error, fatal.
(php7 版本)

install

mac or linux:

  1. wget https://github.com/shukean/php-yklogger.git
  2. unzip master.php
  3. phpize
  4. ./configure --with-php-config=your_php_path/php-config
  5. make && make install

php.ini

[YkLogger]
ykgogger.auto_flush_num = 50  

达到多少条日志时, 才开始写入文件.
当request 结束时, 也会写入.

init

date_default_timezone_set('Etc/GMT-8');  
 YkLogger::init([  
    'logFile' => path,  
    'logLevel' => level  
]);  

path 为日志存放目录.
level 为日志级别. 低于级别的方法调用不会写入日志. 日志级别定义的有常量, 分别为:

1.YKLOGGER_LEVEL_DEBUG
2.YKLOGGER_LEVEL_INFO
3.YKLOGGER_LEVEL_WARN
4.YKLOGGER_LEVEL_ERROR
5.YKLOGGER_LEVEL_FATAL

methods

YkLogger::debug(string $message, uint $errno = 0, arary $params = []);  
YkLogger::info(string $message, uint $errno = 0 , arary $params = []); //  YkLogger::trace 是info的别名  
YkLogger::warn(string $message, uint $errno = 0, arary $params = []);  
YkLogger::error(string $message, uint $errno = 0, arary $params = []);  
YkLogger::fatal(string $message, uint $errno = 0, arary $params = []);  

methods argument

$message 日志描述
$errno 错误码
$params 需要记录的其他字段信息, 二维数组将会转为json存入

other methods

YkLogger::resetRequestTime(uint timestamp = 0); // YkLogger::reset_request_time 是resetRequestTime的别名
重置初始化的时间

string $request_id = YkLogger::getRequestId(); // YkLogger::get_request_id 是getRequestId的别名
获取本次request的随机ID, 不保证不会重复

log file

etc: api.2015052314 api.wf.2015052314
wf 为 warn error fatal 的日志, 日志按小时划分.
logFile 最后一个斜线的字符为日志文件的前缀.

log content

级别 时间 [文件:行数] [php进程号] reqip[IP] uri[uri] refer[url] cost[耗时] errno[0] params message
params 会按照 [key] value 的方式连接.

php-yklogger's People

Contributors

shukean avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-yklogger's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.