You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
6
13
7
14
```bash
8
15
composer require hejunjie/error-log
9
16
```
10
17
11
-
## 使用方式
18
+
## Usage
12
19
13
20
```php
14
21
<?php
@@ -17,66 +24,61 @@ use Hejunjie\ErrorLog\Logger;
17
24
use Hejunjie\ErrorLog\Handlers;
18
25
19
26
$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
23
30
]);
24
31
25
-
$log->info('标题','内容',['上下文']); // INFO 级
26
-
$log->warning('标题','内容',['上下文']); // WARNING 级
27
-
$log->error('标题','内容',['上下文']); // ERROR 级
32
+
$log->info('title','content',['Context']); // INFO Level
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.
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.
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.
[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.
[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.
[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
[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.
75
69
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.
76
71
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.
77
73
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.
78
75
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.
79
77
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.
80
79
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!
81
81
82
+
---
82
83
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.
"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.",
0 commit comments