twidpay/twid-logger 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

twidpay/twid-logger

最新稳定版本:3.0.0

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.

统计信息

  • 总下载量: 10.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-05