Download the PHP package hehex/hehep-hlogger without Composer

On this page you can find all versions of the php package hehex/hehep-hlogger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hehep-hlogger

hehep-hlogger

介绍

hehep-hlogger 是一个PHP 日志工具组件,仿python logging模块
支持处理器、过滤器、格式器、上下文

安装

组件配置

基本示例

日志管理器

用于管理日志相关的操作,比如
配置日志处理器,日志格式器,日志过滤器,日志记录器,
创建日志记录器,日志处理器,日志格式器,志过滤器的对象,
记录不同级别日志

日志管理器示例

预定义配置

日志记录器

类名:hehe\core\hlogger\base\Logger
作用:用于记录日志,可以设置日志级别,日志过滤器,日志处理器
属性:
'bufferLimit'=>0,// 缓冲日志数量
'handlers'=>['default'],// 日志处理器
'levels'=>['info','error','warning','debug'],// 设置允许的消息级别
'categorys'=>['admin\controller*'],// 设置允许的日志类别
'filter'=>'info',// 定义过滤器
'formatter'=>'default',// 定义日志格式器

创建日志记录器

日志消息对象

类名:hehe\core\hlogger\base\Message
作用:用于存储日志消息,级别,上下文对象

示例代码

日志处理器

基类:hehe\core\hlogger\handlers\LogHandler
作用:持久化日志信息,比如文件处理器,数据库处理器,邮件处理器等等
全局属性:
'filter'=>'',// 日志过滤器
'formatter'=>'',// 日志格式器

预定义处理器

自定义处理器

必须继承基类:hehe\core\hlogger\handlers\LogHandler,并实现方法:handleMessage()

创建处理器对象

文件处理器

基类:hehe\core\hlogger\handlers\FileHandler
属性:
'logFile'=>'',// 日志文件
'useLock'=>false,// 是否使用文件锁(flock),默认为false

文件大小轮转处理器

类名:hehe\core\hlogger\handlers\ByteRotatingFileHandler, 继承自RotatingFileHandler
属性:
'logFile'=>'',// 日志文件
'maxByte'=>0,// 最大文件容量,单kb,日志文件超过该值时,将创建新的日志文件
'rotatefmt'=>'{filename}',// 轮转文件格式,变量可以取自日志上下文, filename:当前日志文件名
'rotatefmtParams'=>['filename'=>'\w+'],// 轮转文件格式参数,可设置变量的正则表达式
'backupCount'=>0,// 最大备份文件数量,默认为0,表示不限制
'backupfmt'=>'{filename}_up{index}',// 备份文件格式,变量可以取自日志上下文, filename:当前轮转文件名 ,index:自增序号 日期格式
'backupfmtParams'=>['index'=>'\d+'],// 备份文件格式参数,可设置变量的正则表达式

轮转文件名支持上下文变量,如:{filename}{pid},pid:当前进程id
备份文件名支持上下文变量,如:{filename}
{pid},pid:当前进程id

文件日期轮转处理器

类名:hehe\core\hlogger\handlers\TimedRotatingFileHandler, 继承自RotatingFileHandler
属性:
'logFile'=>'',// 日志文件
'rotateMode'=>'d',// 日志轮转模式,支持d(天),h(小时),m(月),s(分钟),w(周),y(年),默认为d,表示按天轮转
'rotatefmt'=>'{filename}_{date:YmdHi}_hehe',// 轮转文件格式,变量可以取自日志上下文,
// filename:当前日志文件名 ,date:为当前日期,"YmdHi" 日期格式
'rotatefmtParams'=>['filename'=>'\w+'],// 轮转文件格式参数,可设置变量的正则表达式
'maxFile'=>0,// 最大文件数量,默认为0,表示不限制'
'maxByte'=>0,// 最大文件容量,单kb,日志文件超过该值时,将创建新的日志文件
'backupCount'=>0,// 最大备份文件数量,默认为0,表示不限制
'backupfmt'=>'{filename}_up{index}',// 备份文件格式,变量可以取自日志上下文,
// filename:当前轮转文件名 ,index:自增序号
'backupfmtParams'=>['index'=>'\d+'],// 备份文件格式参数,可设置变量的正则表达式

轮转文件名支持上下文变量,如:{filename}{pid},pid:当前进程id
备份文件名支持上下文变量,如:{filename}
{pid},pid:当前进程id

扩展文件轮转处理器

继承:hehe\core\hlogger\handlers\RotatingFileHandler
属性:
'logFile'=>'',// 日志文件
'rotating'=>null,// 轮转状态,true 表示正在轮转中(日志文件未生成)
'maxFiles'=>0,// 最大文件数量,默认为0,表示不限制
'rotatefmt'=>'',// 轮转文件格式,变量可以取自日志上下文,
'rotatefmtParams'=>[],// 轮转文件格式参数,可设置变量的正则表达式
'backupCount'=>0,// 最大备份文件数量,默认为0,表示不限制
'backupfmt'=>'',// 备份文件格式,变量可以取自日志上下文,
'backupfmtParams'=>[],// 备份文件格式参数,可设置变量的正则表达式

日志过滤器

基类:hehe\core\hlogger\base\LogFilter
作用:过滤日志消息,比如只记录error级别日志,或者只记录"admin\controller"控制器的日志
属性:
'levels'=>'info,error',// 支持的日志级别
'categorys'=>['admin\controller
'],// 支持的日志分类

预定义过滤器

自定义过滤器

必须继承基类:hehe\core\hlogger\base\LogFilter,并重写check方法

创建过滤器对象

日志格式器

基类:hehe\core\hlogger\base\LogFormatter
作用:格式化日志消息,比如将日志消息转换为字符串

预定义日志格式器

自定义日志格式器

创建格式器对象

单行字符串日志格式器

日志上下文

预定义日志上下文

自定义日志上下文

必须继承基类:hehe\core\hlogger\base\LogContext,并重写handle方法

日志上下文示例

trace上下文

基类:hehe\core\hlogger\contexts\TraceContext
变量:
file:文件路径,基本格式:{file}
line:行数,基本格式:{line}
class:类名,基本格式:{class}
fn:方法名,基本格式:{fn}

系统上下文

基类:hehe\core\hlogger\contexts\SysContext
变量:
pid:进程ID,基本格式:{pid}
tid:线程ID,基本格式:{tid}
date:日期,基本格式:{date:Y-m-d:H:i}
time:时间戳,微妙,基本格式:{time}
maxMemory:最大内存,基本格式:{maxMemory}
useMemory:当前脚本占用的内存,基本格式:{useMemory}
n:换行符,'\n',基本格式:{n}


All versions of hehep-hlogger with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hehex/hehep-hlogger contains the following files

Loading the files please wait ....