Giter Site home page Giter Site logo

seasx / seaslog Goto Github PK

View Code? Open in Web Editor NEW
1.2K 105.0 277.0 1.67 MB

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

PHP 4.74% C 94.40% M4 0.50% JavaScript 0.25% Shell 0.11%
php-extension buffer-size log4php psr-3

seaslog's People

Contributors

769344359 avatar ade951 avatar aiwhj avatar amuluowin avatar daxiong123 avatar defender-11 avatar easydowork avatar fengzhulei avatar guolifu avatar hello2t avatar her-cat avatar hi-man avatar hushulin avatar hy0kl avatar liyang1009 avatar lovelock avatar neeke avatar nly avatar petk avatar rock-lee-520 avatar sch0ng avatar sidkwok avatar vibbow avatar viest avatar vissong avatar wujunze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seaslog's Issues

Mac OSX 10.9.4 编译报错

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;
            ^      ~~~~~~~~~~

添加disting_type

优化文件写入与读取性能,
添加disting_type,
依error type分文件

手动刷新缓冲区功能

seaslog 可不可以增加一个手动刷新缓存的接口?
我这边是想用seaslog 用在后台程序里面,所以不存在一次请求结束的情况,因此需要我手动去刷新缓冲区

谢谢

Mac下编译出错,希望能解决,或给个解决方案,c小白期待中

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 下的bug

我设置了
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 无论怎么设置都一样

MAC type划分文件,统计所有错误数据报错

  1. 初始统计数据报分类错误文件不存在
  2. 单独显示指定错误,初始化报错,日志存在,数据位一,二次统计得出数据错误需+1

操作系统

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

redis server went away

使用phpredis扩展的2.2.3版本 会报这个异常,只是异常,redis 连接 读取 不受影响
升级2.2.5后异常消失.可否向下兼容?

type只能用all了

最新版本只能获取全部日志了,无法获取分类下的日志了
Seaslog::analyzerDetail(SEASLOG_ERROR);

增加 log.level 配置项

能否在配置项增加 log.level 项,同样的代码可以做到开发环境写 debug 日志,而线上生产环境却不写,以节省磁盘空间,提高性能.

简单看了一下,不支持log收集汇总

在我们实际业务场景里,业务机器将近20台,如果log都打在各自服务器的本地,那最后出了问题,还是不知道去哪里查的。最好能将log都通过网络输送到一个固定的服务器,那个服务器能够分模块打印log

fix seaslog_analyzer_detail strange

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配置项

当添加use_buffer配置,并启用时,日志存在内存中,
在请求结束或异常退出时,日志才最终写文件,以降低IO。

use_buffer 是不是有什么问题啊

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'); 差不多

编译扩展出错 make: *** [seaslog.lo] Error 1

/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个文件,高访问时需配置文件时间粒度,
如:每两小时一个文件,甚至每半小时一个文件。

是否可以考虑Buffer部分再做些优化,例如加入Buffer Size

看到最近的两次commit,对此项目来说意义很大啊。

是否可以考虑增加Buffer Size选项来控制刷新到文件的时机,因部分复杂的项目在日志记录泛滥的情况下,所有日志都在内存中只进行一次刷新,是否再此过程中会导致内存占用过多的情况。

dead loop issue

PHP 5.3.17

<?php
ini_set('display_errors', 0);
try {
    throw new Exception("e1");
} catch (Exception $ex) {
    echo $ex->getMessage();
}

mac-analyzerDetail

SeasLog::analyzerDetail(SEASLOG_ERROR);
SeasLog::analyzerDetail(SEASLOG_ERROR);
SeasLog::analyzerDetail(SEASLOG_ERROR,date('Ymd',time()));
写入了日志,打印为空

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.