seasx / seaslog Goto Github PK
View Code? Open in Web Editor NEWAn effective,fast,stable log extension for PHP.http://pecl.php.net/package/SeasLog http://php.net/SeasLog
Home Page: http://seasx.github.io/SeasLog/
License: Other
An effective,fast,stable log extension for PHP.http://pecl.php.net/package/SeasLog http://php.net/SeasLog
Home Page: http://seasx.github.io/SeasLog/
License: Other
using TSRMLS_FETCH()
in some PHP_FUNCTION, this won't compile in tsrm mode.
(duplicate tsrmls declaration)
可否考虑直接将php错误日志自动做记录?因为一些致命错误在php运行的时候会导致php停止执行,如果特意捕捉的话还是麻烦的
not support for PHP 7.0.0 alpha2
fatal error: ext/standard/php_smart_str.h: No such file or directory
PHP 5.5.12 (cli) (built: May 17 2014 23:42:09)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
错误信息:
/pathSeasLog/SeasLog/seaslog.c:277:13: error: void function 'seaslog_shutdown_buffer' should not return a value
[-Wreturn-type]
return (zval *) 0;
^ ~~~~~~~~~~
有没有windows版本的SeasLog
优化文件写入与读取性能,
添加disting_type,
依error type分文件
seaslog 可不可以增加一个手动刷新缓存的接口?
我这边是想用seaslog 用在后台程序里面,所以不存在一次请求结束的情况,因此需要我手动去刷新缓冲区
谢谢
cc -v显示如下
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
错误信息如下:
/Users/tinder1024/beequick/test/SeasLog/SeasLog/seaslog.c:392:19: warning: implicit declaration of function '_ck_log_dir' is
invalid in C99 [-Wimplicit-function-declaration]
int _ck_dir = _ck_log_dir(_log_path);
^
/Users/tinder1024/beequick/test/SeasLog/SeasLog/seaslog.c:472:13: warning: implicit declaration of function
'_seaslog_log_content' is invalid in C99 [-Wimplicit-function-declaration]
if (_seaslog_log_content(argc,level,message,message_len,HASH_OF(_content),logger,logger_len TSRMLS_CC) == FAILURE) {
^
/Users/tinder1024/beequick/test/SeasLog/SeasLog/seaslog.c:476:13: warning: implicit declaration of function '_seaslog_log' is
invalid in C99 [-Wimplicit-function-declaration]
if (_seaslog_log(argc,level,message,message_len,logger,logger_len TSRMLS_CC) == FAILURE) {
^
/Users/tinder1024/beequick/test/SeasLog/SeasLog/seaslog.c:735:17: error: non-void function 'php_strtr_array' should return a
value [-Wreturn-type]
return;
^
/Users/tinder1024/beequick/test/SeasLog/SeasLog/seaslog.c:839:9: warning: implicit declaration of function '_check_level' is
invalid in C99 [-Wimplicit-function-declaration]
if (_check_level(level TSRMLS_CC) == FAILURE) {
^
/Users/tinder1024/beequick/test/SeasLog/SeasLog/seaslog.c:844:5: warning: implicit declaration of function '_mk_log_dir' is
invalid in C99 [-Wimplicit-function-declaration]
_mk_log_dir(_log_path);
^
/Users/tinder1024/beequick/test/SeasLog/SeasLog/seaslog.c:854:9: warning: implicit declaration of function '_php_log_ex' is
invalid in C99 [-Wimplicit-function-declaration]
if (php_log_ex(log_info, log_len, log_file_path TSRMLS_CC) == FAILURE) {
^
6 warnings and 1 error generated.
make: ** [seaslog.lo] Error 1
本地环境是mac 线上是centos ,在使用seaslog碰到很多问题,希望能支持mac,具体问题 能够记录如理 读取内容为空 统计有数据
我设置了
seaslog.default_basepath = /Users/zhanghao/www/logs
seaslog.default_logger = default
但是日志还是只记到/Users/zhanghao/www/logs 目录下,没到default目录下,怎么回事?
用Seaslog::analyzerDetail('all'), 获取到的是空数组,获取不到全部日志
而且我必须先执行下记录的行为才能获取Seaslog::analyzerDetail()的内容,比如必须这样才能获取
Seaslog:debug("test");
$list = Seaslog::analyzerDetail("debug");
这样$list才有内容
单单用$list = Seaslog::analyzerDetail("debug"); $list是空数组
配置如下:
extension = seaslog.so
seaslog.default_basepath = /Users/zhanghao/www/logs ;默认log根目录
seaslog.default_logger = default ;默认logger目录
seaslog.disting_type = 1 ;是否以type分文件 1是 0否(默认)
seaslog.disting_by_hour = 0 ;是否每小时划分一个文件 1是 0否(默认)
seaslog.use_buffer = 1 ;是否启用buffer 1是 0否(默认)
seaslog.buffer_size = 10 ;buffer中缓冲数量 默认0(不使用buffer_size)
seaslog.level = 0 ;记录日志级别 默认0(所有日志)
seaslog.use_buffer和seaslog.buffer_size = 10 无论怎么设置都一样
初步完成Analyzer脚本框架。
暂不考虑视图展示、视图保存、重复统计等问题
更新接口调用
操作系统
Darwin HuangXideMacBook-Air.local 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
SeasLog
1.1.4
PHP
5.5.19
统计全部
代码
<?php
ini_set('seaslog.disting_type', 1);
$countResult = SeasLog::analyzerCount();
ini_set('seaslog.disting_type', 1);
SeasLog::setBasePath(realpath('.'));
SeasLog::setLogger('log');
SeasLog::info('log info test');
print_r($countResult);
错误信息
/webroot/public/log/debug.*: No such file or directory
/webroot/public/log/notice.*: No such file or directory
/webroot/public/log/warning.*: No such file or directory
/webroot/public/log/error.*: No such file or directory
/webroot/public/log/critical.*: No such file or directory
/webroot/public/log/alert.*: No such file or directory
/webroot/public/log/emergency.*: No such file or directory
Array
(
[debug] => 0
[info] => 0
[notice] => 0
[warning] => 0
[error] => 0
[critical] => 0
[alert] => 0
[emergency] => 0
)
单独统计
代码
ini_set('seaslog.disting_type', 0);
SeasLog::setBasePath(realpath('.'));
SeasLog::setLogger('log');
SeasLog::info('log info test');
$countResult = SeasLog::analyzerCount(SEASLOG_INFO);
print_r($countResult);
一次结果
/webroot/yaf/public/log/*: No such file or directory
0
二次结果
1
日志
info | 3659 | 1424924279.933 | 2015:02:26 12:17:59 | log info test
info | 3665 | 1424924364.42 | 2015:02:26 12:19:24 | log info test
it's a bug
对于web服务来说,请求的URL、Method所执行File line对于检查系统可能存在的问题来说意义重大,建议增加这些选项作为format的可定制参数,如果这么做了,同时请考虑cli下的记录
使用phpredis扩展的2.2.3版本 会报这个异常,只是异常,redis 连接 读取 不受影响
升级2.2.5后异常消失.可否向下兼容?
给个执行结果看看,文档也没有
最新版本只能获取全部日志了,无法获取分类下的日志了
Seaslog::analyzerDetail(SEASLOG_ERROR);
hi mac 藐视有bug
完善接口
能否在配置项增加 log.level 项,同样的代码可以做到开发环境写 debug 日志,而线上生产环境却不写,以节省磁盘空间,提高性能.
在我们实际业务场景里,业务机器将近20台,如果log都打在各自服务器的本地,那最后出了问题,还是不知道去哪里查的。最好能将log都通过网络输送到一个固定的服务器,那个服务器能够分模块打印log
this code in PHP_FUNCTION (seaslog_analyzer_detail) looks
strange:
if (type == SEASLOG_TYPE_INFO){
type = SEASLOG_TYPE_INFO;
}else if(type == SEASLOG_TYPE_WARN){
type = SEASLOG_TYPE_WARN;
...
当添加use_buffer配置,并启用时,日志存在内存中,
在请求结束或异常退出时,日志才最终写文件,以降低IO。
tks
PHP 5.3.13
seaslog.use_buffer = 1
seaslog.buffer_size = 100
./ab -n 100000 -c 10 http://test.com/testseas_log.php
代码如下:
error('test is a test'); 最后打出来300行,我预期是能打出来10万行的…… 如果不设置 use_buffer 的话,没什么问题…… 性能跟 error_log('error | 25561 | 1408013704.705 | 2014:08:14 18:55:04 | test is a test' . "\n" , 3, '/tmp/error_log.log'); 差不多/usr/local/src/SeasLog-1.1.4/SeasLog/seaslog.c:50: note: previous declaration of ‘_php_log_ex’ was here
make: *** [seaslog.lo] Error 1
PHP 5.5.18 (cli) (built: Oct 22 2014 09:57:19)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
CentOS 6.3 x86_64
使用 SeasLog::getBasePath() 函数,将改变 seaslog_get_basepath() 的取值。
这里应该是getBasePath();
常量SEASLOG_ERRO有错应该是SEASLOG_ERROR
请问,可不可为跑在同一台服务器上的不周项目配置不同的日志级别?
如果可以,如何操作?谢谢。
默认为每天1个文件,高访问时需配置文件时间粒度,
如:每两小时一个文件,甚至每半小时一个文件。
看到最近的两次commit,对此项目来说意义很大啊。
是否可以考虑增加Buffer Size选项来控制刷新到文件的时机,因部分复杂的项目在日志记录泛滥的情况下,所有日志都在内存中只进行一次刷新,是否再此过程中会导致内存占用过多的情况。
PHP 5.3.17
<?php
ini_set('display_errors', 0);
try {
throw new Exception("e1");
} catch (Exception $ex) {
echo $ex->getMessage();
}
SeasLog::analyzerDetail(SEASLOG_ERROR);
SeasLog::analyzerDetail(SEASLOG_ERROR);
SeasLog::analyzerDetail(SEASLOG_ERROR,date('Ymd',time()));
写入了日志,打印为空
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.