定制 calguy1000/logger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

calguy1000/logger

Composer 安装命令:

composer require calguy1000/logger

包简介

A powerful application logging, and log querying tool.

README 文档

README

A simple logging utility with rotation, concurrency, repeat counting and search support.

This library provides the ability for your application to log debug messages, info messages, warnings and errors to a text file. The library supports rotation, counting sequentially repeated messages, writing to the same file from multiple processes, and querying the files. It is suitable for applications that need various amounts of debugging, logging or auditing capabilities.

Features

  • Provides a simple, extensible mechanism for allowing an application to perform logging.
  • Provides a logging interface
  • FileLogger class Can count identical sequental messages
  • Can track separate (or combined) keys. Known as a "section" and an "item"
  • AutoRotateFileLogger supports log rotation based on file size (kilobytes) or age (hours) and maximum number of files.
  • Uses exclusive locking to lock filed for writing
  • Supports simple querying of saved log files

Simple logging to a file

require '../vendor/autoload.php'
use calguy1000\logger\FileLogger as FileLogger;
$logger = new FileLogger('logfile.txt');
$logger->debug('A debug message');
$logger->info('An information message');
$logger->warn('A warning message');
$logger->error('A fatal error');

Using the auto-rotate logger

require '../vendor/autoload.php'
use calguy1000\logger\AutoRotateFileLogger as AutoRotateFileLogger;
$logger = new AutoRotateFileLogger('logfile.txt',24,2000,30);
$logger->debug('A debug message');
$logger->info('An information message');
$logger->warn('A warning message');
$logger->error('A fatal error');

Querying the logs

require '../vendor/autoload.php'
use calguy1000\logger\Logger as Logger;
$parms = [ 'filename'=>'logfile.txt','limit'=>50,'msg'=>'*fatal*` ];
$query = new Logger\query($parms);
$rs = $query->execute();
foreach( $rs as $key => $item ) {
   print_r($item);
}

Limitations

  • Each log string can be a maximum of 512 bytes
  • Log files can be a maximum of 50mb in size
  • Log files can be a maximum of 60 days old.

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-2.1
  • 更新时间: 2015-08-31