Skip to content

Commit 72a80b6

Browse files
author
苏青安
committed
README调整
1 parent d61f488 commit 72a80b6

File tree

3 files changed

+123
-38
lines changed

3 files changed

+123
-38
lines changed

README.md

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# hejunjie/error-log
22

3-
不同框架通常自带日志系统,但要么强绑定到框架,更换框架就要重构日志方案,要么像 Monolog 这类强大的日志系统功能过于庞大。而为了在不同框架中保持通用性,同时避免过度复杂,我基于责任链模式实现了一个轻量级的日志模块
3+
<div align="center">
4+
<a href="./README.md">English</a>|<a href="./README.zh-CN.md">简体中文</a>
5+
<hr width="50%"/>
6+
</div>
47

5-
## 安装方式
8+
An error logging component using the Chain of Responsibility pattern. Supports multiple output channels like local files, remote APIs, and console logs—ideal for flexible and scalable logging strategies.
9+
10+
## Installation
11+
12+
Install via Composer:
613

714
```bash
815
composer require hejunjie/error-log
916
```
1017

11-
## 使用方式
18+
## Usage
1219

1320
```php
1421
<?php
@@ -17,66 +24,61 @@ use Hejunjie\ErrorLog\Logger;
1724
use Hejunjie\ErrorLog\Handlers;
1825

1926
$log = new Logger([
20-
new Handlers\ConsoleHandler(), // 打印到控制台
21-
new Handlers\FileHandler('日志存储文件夹路径'), // 存储到文件
22-
new Handlers\RemoteApiHandler('请求url') // 发送到某个地址
27+
new Handlers\ConsoleHandler(), // Print to console
28+
new Handlers\FileHandler('path'), // Save to file
29+
new Handlers\RemoteApiHandler('url') // Send to a specific address
2330
]);
2431

25-
$log->info('标题','内容',['上下文']); // INFO
26-
$log->warning('标题','内容',['上下文']); // WARNING
27-
$log->error('标题','内容',['上下文']); // ERROR
32+
$log->info('title','content',['Context']); // INFO Level
33+
$log->warning('title','content',['Context']); // WARNING Level
34+
$log->error('title','content',['Context']); // ERROR Level
2835

29-
$log->log('自定义级别','标题','内容',['上下文']);
36+
$log->log('level','title','content',['Context']);
3037
```
3138

32-
## 用途 & 初衷
39+
## Purpose & Original Intent
3340

34-
这个组件的起因其实很简单:
35-
代码跑在不同的服务器上,有的安静得像退休老头,有的动不动炸成烟花——但它们都在跑“同一份代码”,每次炸了还都来找我。
41+
The origin of this component is actually quite simple:
42+
The code runs on different servers, some are as quiet as retired old men, while others explode into fireworks at the slightest provocation — but they're all running "the same code," and every time something breaks, they come looking for me.
3643

37-
最离谱的是,每个人都说是“最新版”,但到底是代码问题、环境问题、部署问题,谁知道?
38-
于是我写了这个小东西:让日志可以灵活地 输出到文件、控制台、远程服务器,最好还能自定义格式,让我在被质问之前,先找到锅。
44+
The most absurd part is that everyone claims they’re running the "latest version," but whether it's a code issue, an environment issue, or a deployment issue, who knows?
45+
So, I wrote this little tool: to flexibly output logs to files, consoles, and remote servers, with customizable formats. This way, I can find the problem before I'm questioned.
3946

40-
后来还写了个日志接收小脚本,配合这个组件可以把远程日志直接展示出来,用来接收、展示、筛选、管理日志错误信息:
47+
Later, I also wrote a small log receiving script. Combined with this component, it can directly display remote logs, allowing me to receive, display, filter, and manage log error information.
4148

4249
👉 [oh-shit-logger](https://github.com/zxc7563598/oh-shit-logger)
4350

44-
## 🔧 更多工具包(可独立使用,也可统一安装)
51+
## 🔧 Additional Toolkits (Can be used independently or installed together)
4552

46-
本项目最初是从 [hejunjie/tools](https://github.com/zxc7563598/php-tools) 拆分而来,如果你想一次性安装所有功能组件,也可以使用统一包:
53+
This project was originally extracted from [hejunjie/tools](https://github.com/zxc7563598/php-tools).
54+
To install all features in one go, feel free to use the all-in-one package:
4755

4856
```bash
4957
composer require hejunjie/tools
5058
```
5159

52-
当然你也可以按需选择安装以下功能模块:
53-
54-
[hejunjie/cache](https://github.com/zxc7563598/php-cache) - 多层缓存系统,基于装饰器模式。
60+
Alternatively, feel free to install only the modules you need:
5561

56-
[hejunjie/china-division](https://github.com/zxc7563598/php-china-division) - 中国省市区划分数据包。
62+
[hejunjie/utils](https://github.com/zxc7563598/php-utils) - A lightweight and practical PHP utility library that offers a collection of commonly used helper functions for files, strings, arrays, and HTTP requests—designed to streamline development and support everyday PHP projects.
5763

58-
[hejunjie/mobile-locator](https://github.com/zxc7563598/php-mobile-locator) - 国内手机号归属地 & 运营商识别。
64+
[hejunjie/cache](https://github.com/zxc7563598/php-cache) - A layered caching system built with the decorator pattern. Supports combining memory, file, local, and remote caches to improve hit rates and simplify cache logic.
5965

60-
[hejunjie/utils](https://github.com/zxc7563598/php-utils) - 常用工具方法集合。
66+
[hejunjie/china-division](https://github.com/zxc7563598/php-china-division) - Regularly updated dataset of China's administrative divisions with ID-card address parsing. Distributed via Composer and versioned for use in forms, validation, and address-related features
6167

62-
[hejunjie/address-parser](https://github.com/zxc7563598/php-address-parser) - 收货地址智能解析工具,支持从非结构化文本中提取用户/地址信息。
63-
64-
[hejunjie/url-signer](https://github.com/zxc7563598/php-url-signer) - URL 签名工具,支持对 URL 进行签名和验证。
65-
66-
[hejunjie/google-authenticator](https://github.com/zxc7563598/php-google-authenticator) - Google Authenticator 及类似应用的密钥生成、二维码创建和 OTP 验证。
67-
68-
[hejunjie/simple-rule-engine](https://github.com/zxc7563598/php-simple-rule-engine) - 一个轻量、易用的 PHP 规则引擎,支持多条件组合、动态规则执行。
69-
70-
👀 所有包都遵循「轻量实用、解放双手」的原则,能单独用,也能组合用,自由度高,欢迎 star 🌟 或提 issue。
71-
72-
---
73-
74-
该库后续将持续更新,添加更多实用功能。欢迎大家提供建议和反馈,我会根据大家的意见实现新的功能,共同提升开发效率。
68+
[hejunjie/error-log](https://github.com/zxc7563598/php-error-log) - An error logging component using the Chain of Responsibility pattern. Supports multiple output channels like local files, remote APIs, and console logs—ideal for flexible and scalable logging strategies.
7569

70+
[hejunjie/mobile-locator](https://github.com/zxc7563598/php-mobile-locator) - A mobile number lookup library based on Chinese carrier rules. Identifies carriers and regions, suitable for registration checks, user profiling, and data archiving.
7671

72+
[hejunjie/address-parser](https://github.com/zxc7563598/php-address-parser) - An intelligent address parser that extracts name, phone number, ID number, region, and detailed address from unstructured text—perfect for e-commerce, logistics, and CRM systems.
7773

74+
[hejunjie/url-signer](https://github.com/zxc7563598/php-url-signer) - A PHP library for generating URLs with encryption and signature protection—useful for secure resource access and tamper-proof links.
7875

76+
[hejunjie/google-authenticator](https://github.com/zxc7563598/php-google-authenticator) - A PHP library for generating and verifying Time-Based One-Time Passwords (TOTP). Compatible with Google Authenticator and similar apps, with features like secret generation, QR code creation, and OTP verification.
7977

78+
[hejunjie/simple-rule-engine](https://github.com/zxc7563598/php-simple-rule-engine) - A lightweight and flexible PHP rule engine supporting complex conditions and dynamic rule execution—ideal for business logic evaluation and data validation.
8079

80+
👀 All packages follow the principles of being lightweight and practical — designed to save you time and effort. They can be used individually or combined flexibly. Feel free to ⭐ star the project or open an issue anytime!
8181

82+
---
8283

84+
This library will continue to be updated with more practical features. Suggestions and feedback are always welcome — I’ll prioritize new functionality based on community input to help improve development efficiency together.

README.zh-CN.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# hejunjie/error-log
2+
3+
<div align="center">
4+
<a href="./README.md">English</a>|<a href="./README.zh-CN.md">简体中文</a>
5+
<hr width="50%"/>
6+
</div>
7+
8+
基于责任链模式的错误日志处理组件,支持多通道日志处理(如本地文件、远程 API、控制台输出),适用于复杂日志策略场景。
9+
10+
## 安装方式
11+
12+
使用 Composer 安装:
13+
14+
```bash
15+
composer require hejunjie/error-log
16+
```
17+
18+
## 使用方式
19+
20+
```php
21+
<?php
22+
23+
use Hejunjie\ErrorLog\Logger;
24+
use Hejunjie\ErrorLog\Handlers;
25+
26+
$log = new Logger([
27+
new Handlers\ConsoleHandler(), // 打印到控制台
28+
new Handlers\FileHandler('日志存储文件夹路径'), // 存储到文件
29+
new Handlers\RemoteApiHandler('请求url') // 发送到某个地址
30+
]);
31+
32+
$log->info('标题','内容',['上下文']); // INFO 级
33+
$log->warning('标题','内容',['上下文']); // WARNING 级
34+
$log->error('标题','内容',['上下文']); // ERROR 级
35+
36+
$log->log('自定义级别','标题','内容',['上下文']);
37+
```
38+
39+
## 用途 & 初衷
40+
41+
这个组件的起因其实很简单:
42+
代码跑在不同的服务器上,有的安静得像退休老头,有的动不动炸成烟花——但它们都在跑“同一份代码”,每次炸了还都来找我。
43+
44+
最离谱的是,每个人都说是“最新版”,但到底是代码问题、环境问题、部署问题,谁知道?
45+
于是我写了这个小东西:让日志可以灵活地 输出到文件、控制台、远程服务器,最好还能自定义格式,让我在被质问之前,先找到锅。
46+
47+
后来还写了个日志接收小脚本,配合这个组件可以把远程日志直接展示出来,用来接收、展示、筛选、管理日志错误信息:
48+
49+
👉 [oh-shit-logger](https://github.com/zxc7563598/oh-shit-logger)
50+
51+
## 🔧 更多工具包(可独立使用,也可统一安装)
52+
53+
本项目最初是从 [hejunjie/tools](https://github.com/zxc7563598/php-tools) 拆分而来,如果你想一次性安装所有功能组件,也可以使用统一包:
54+
55+
```bash
56+
composer require hejunjie/tools
57+
```
58+
59+
当然你也可以按需选择安装以下功能模块:
60+
61+
[hejunjie/utils](https://github.com/zxc7563598/php-utils) - 一个零碎但实用的 PHP 工具函数集合库。包含文件、字符串、数组、网络请求等常用函数的工具类集合,提升开发效率,适用于日常 PHP 项目辅助功能。
62+
63+
[hejunjie/cache](https://github.com/zxc7563598/php-cache) - 基于装饰器模式实现的多层缓存系统,支持内存、文件、本地与远程缓存组合,提升缓存命中率,简化缓存管理逻辑。
64+
65+
[hejunjie/china-division](https://github.com/zxc7563598/php-china-division) - 定期更新,全国最新省市区划分数据,身份证号码解析地址,支持 Composer 安装与版本控制,适用于表单选项、数据校验、地址解析等场景。
66+
67+
[hejunjie/error-log](https://github.com/zxc7563598/php-error-log) - 基于责任链模式的错误日志处理组件,支持多通道日志处理(如本地文件、远程 API、控制台输出),适用于复杂日志策略场景。
68+
69+
[hejunjie/mobile-locator](https://github.com/zxc7563598/php-mobile-locator) - 基于国内号段规则的手机号码归属地查询库,支持运营商识别与地区定位,适用于注册验证、用户画像、数据归档等场景。
70+
71+
[hejunjie/address-parser](https://github.com/zxc7563598/php-address-parser) - 收货地址智能解析工具,支持从非结构化文本中提取姓名、手机号、身份证号、省市区、详细地址等字段,适用于电商、物流、CRM 等系统。
72+
73+
[hejunjie/url-signer](https://github.com/zxc7563598/php-url-signer) - 用于生成带签名和加密保护的URL链接的PHP工具包,适用于需要保护资源访问的场景
74+
75+
[hejunjie/google-authenticator](https://github.com/zxc7563598/php-google-authenticator) - 一个用于生成和验证时间基础一次性密码(TOTP)的 PHP 包,支持 Google Authenticator 及类似应用。功能包括密钥生成、二维码创建和 OTP 验证。
76+
77+
[hejunjie/simple-rule-engine](https://github.com/zxc7563598/php-simple-rule-engine) - 一个轻量、易用的 PHP 规则引擎,支持多条件组合、动态规则执行,适合业务规则判断、数据校验等场景。
78+
79+
👀 所有包都遵循「轻量实用、解放双手」的原则,能单独用,也能组合用,自由度高,欢迎 star 🌟 或提 issue。
80+
81+
---
82+
83+
该库后续将持续更新,添加更多实用功能。欢迎大家提供建议和反馈,我会根据大家的意见实现新的功能,共同提升开发效率。

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hejunjie/error-log",
3-
"description": "基于责任链模式的错误日志处理组件,支持多通道日志处理(如本地文件、远程 API、控制台输出),适用于复杂日志策略场景。",
3+
"description": "An error logging component using the Chain of Responsibility pattern. Supports multiple output channels like local files, remote APIs, and console logs—ideal for flexible and scalable logging strategies.",
44
"license": "MIT",
55
"type": "library",
66
"autoload": {

0 commit comments

Comments
 (0)