submtd / laravel-custom-log
此包的最新版本(1.0.0)没有可用的许可信息。
在类内部定义自定义日志驱动
1.0.0
2018-08-01 15:32 UTC
Requires
- php: >=5.3
This package is auto-updated.
Last update: 2024-09-13 13:06:59 UTC
README
在Laravel的类内部创建自定义日志。
安装
composer require submtd/laravel-custom-log
用法
将HasCustomLog特性添加到你的类中,并添加一个名为logChannel()的公共静态方法。
<?php
use Submtd\LaravelCustomLog\HasCustomLog;
class Person
{
use HasCustomLog;
/**
* logChannel method
* Method used to define a custom log channel for this class.
* @return array -- return a Laravel log channel array
**/
public static function logChannel()
{
return [
'driver' => 'single',
'path' => storage_path('logs/person.log'),
'level' => 'warning',
];
}
}
日志记录
要将消息记录到自定义日志通道,请调用 static::debug('这是一个日志消息')。
可用的日志方法如下
static::debug($message);
static::info($message);
static::notice($message);
static::warning($message);
static::error($message);
static::critical($message);
static::alert($message);
static::emergency($message);