twidpay/twid-logger
Composer 安装命令:
composer require twidpay/twid-logger
包简介
Centralized logging package for maintaining consistent logging across projects.
README 文档
README
Centralized logging package for maintaining consistent logging across projects.
Installation
You can install this package via Composer:
composer require twidpay/twid-logger
Configuration
Publish the configuration file using the following artisan command:
php artisan vendor:publish --tag=config
This will create a logging.php file in your config directory. You can customize this file to define your log channels, metadata, and masked fields.
Laravel Configuration
Alias
Add the following alias to the aliases array in your config/app.php file:
'TLog' => twid\logger\Facades\TLog::class,
Provider
Add the following service provider to the providers array in your config/app.php file:
twid\logger\TwidLoggerServiceProvider::class,
Lumen Configuration
Alias
Open your bootstrap/app.php file and add the following alias:
class_alias('twid\logger\Facades\TLog', 'TLog');
Provider
Open your bootstrap/app.php file and register the service provider:
$app->register(twid\logger\TwidLoggerServiceProvider::class);
Usage
Facade: TLog
This package provides a facade named TLog for logging messages. You can use this facade to log messages to different channels dynamically.
Example:
use twid\logger\Facades\TLog; // Log an information message to the 'default' channel TLog::info('This is an information message'); // Log an error message to the 'error' channel TLog::error('This is an error message', ['error_code' => 500]);
If you use a channel name as a method, the facade will log the message to that channel. If the method is not explicitly defined, it is treated as a channel name, and the log method is invoked on the corresponding logger instance.
Logger
The Logger class is responsible for handling log messages. It's initialized with a log channel, and you can use it to log messages with specific data.
Example:
use twid\logger\Logger; // Create a logger instance for the 'info' channel $logger = new Logger('info'); // Log a message with additional data $logger->log('This is a log message', ['user_id' => 123]);
License
This package is open-source software licensed under the MIT license.
twidpay/twid-logger 适用场景与选型建议
twidpay/twid-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.83k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 10 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 twidpay/twid-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 twidpay/twid-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-05