jidaikobo/log
Composer 安装命令:
composer require jidaikobo/log
包简介
A simple logging class with error and exception handling. adheres to PSR-1, PSR-12 and PSR-3.
README 文档
README
jidaikobo/log
jidaikobo/log is a simple and flexible logging utility that adheres to the PSR-3 (Logger Interface) standard. It provides both instance-based and static methods for logging, making it easy to integrate into any PHP project.
This package was developed to simplify logging in small-scale projects, such as those using the Slim Framework. It also fulfills the need to log arrays efficiently, which can be crucial for debugging.
Features
- PSR-3 compliant: Supports all standard logging levels.
- Instance-based design: Fully compatible with dependency injection and modern PHP practices.
- Static wrapper: Offers convenient static methods for quick and simple logging.
- Log file rotation: Automatically rotates log files when they reach a specified size.
- Error and exception handling: Integrates with PHP error and exception handling mechanisms.
Installation
Install the package via Composer:
composer require jidaikobo/log
Usage
Basic Initialization
Initialize the logger with a custom log file path and maximum file size (optional):
use Jidaikobo\Log; Log::init('/path/to/log.log', 5 * 1024 * 1024); // 5MB max file size
If Log::init() is not explicitly called, the logger will use default settings.
Logging Messages
Log messages at various levels using static methods:
Log::info('This is an informational message.'); Log::warning('This is a warning message.'); Log::error('An error occurred.'); Log::debug('Debugging details.');
To output an array:
Log::write(['foo', 'bar', 'baz']);
Error and Exception Handling
Register the logger to handle PHP errors and uncaught exceptions:
Log::getInstance()->registerHandlers();
Requirements
- PHP >= 7.4
License
This project is licensed under the MIT License, see the LICENSE file for details
Author
Link
jidaikobo/log 适用场景与选型建议
jidaikobo/log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 164 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jidaikobo/log 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jidaikobo/log 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 164
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-11