smart-contact / smart-log-client
向 Smart Log 应用发送日志的客户端
v1.0.14
2021-05-24 13:33 UTC
Requires
- illuminate/support: ~7|~8
- jenssegers/agent: ^2.6
Requires (Dev)
- orchestra/testbench: ~5|~6
- phpunit/phpunit: ~9.0
This package is auto-updated.
Last update: 2024-09-24 20:54:02 UTC
README
这里应该放置您的描述。请查看 contributing.md 以了解待办事项列表。
安装
通过 Composer
$ composer require smart-contact/smart-log-client
要发布配置,运行 vendor publish 命令
php artisan vendor:publish --provider="SmartLogClient\SmartLogClientServiceProvider"
使用方法
SmartLogClient::report([ 'level' => 'info', //required 'level_code' => '', //required 'status_code' => '', 'user' => 'John Doe', //required 'description' => 'New Log Line', //required 'ip' => 'IP ADDRESS', //required 'registered_at' => 'Y-m-d H:i:s', //default now() 'log' => [ 'key' => 'value', ], 'extra' => [ 'key' => 'value', ], 'formatted' => '', 'user_agent' => 'USER AGENT', //default Jenssegers\Agent::getUserAgent, 'browser' => 'BROWSER', //default Jenssegers\Agent::browser 'browser_version' => 'BROWSER VERSION', //default Jenssegers\Agent::version 'platform' => 'PLATFORM', //default Jenssegers\Agent::plaform 'platform_version' => 'PLATFORM VERSION', //default null ]);
SmartLogClient::info([ 'status_code' => '', 'user' => 'John Doe', //required 'description' => 'New Log Line', //required 'ip' => 'IP ADDRESS', //required 'registered_at' => 'Y-m-d H:i:s', //default now() 'log' => [ 'key' => 'value', ], 'extra' => [ 'key' => 'value', ], 'formatted' => '', 'user_agent' => 'USER AGENT', //default Jenssegers\Agent::getUserAgent, 'browser' => 'BROWSER', //default Jenssegers\Agent::browser 'browser_version' => 'BROWSER VERSION', //default Jenssegers\Agent::version 'platform' => 'PLATFORM', //default Jenssegers\Agent::plaform 'platform_version' => 'PLATFORM VERSION', //default null ]);
可用的日志级别
SmartLogClient::emergency($data); SmartLogClient::critical($data); SmartLogClient::error($data); SmartLogClient::warning($data); SmartLogClient::notice($data); SmartLogClient::info($data); SmartLogClient::debug($data);
Laravel 自定义日志通道
将这些更改应用到 config/logging.php 文件中
'stack' => [ 'driver' => 'stack', 'channels' => ['smartlog','single'], 'ignore_exceptions' => false, ], //Custom Channel 'smartlog' => [ 'driver' => 'custom', 'handler' => \SmartContact\SmartLogClient\Logging\SmartLogHandler::class, 'via' => \SmartContact\SmartLogClient\Logging\SmartLogLogger::class ],
使用 SmartLog 异常处理器
将这些更改应用到 app/Exceptions/Handler.php 文件中
namespace App\Exceptions; class Handler extends \SmartContact\SmartLogClient\Exceptions\Handler { }
跟踪模型的事件
在您想要跟踪的模型中包含 Trait SmartContact\SmartLogClient\Traits\TrackingApplicationLogs
namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use SmartContact\SmartLogClient\Traits\TrackingApplicationLogs; class Order extends Model { use HasFactory, TrackingApplicationLogs; //Default public static $recordEvents = [ 'retrieved', 'created', 'updated', 'deleted', 'restored' // if the model include SoftDeletes trait ]; }
变更日志
请参阅 changelog 了解最近更改的详细信息。
测试
$ composer test
贡献
请参阅 contributing.md 了解详细信息及待办事项列表。
安全性
如果您发现任何安全相关的问题,请通过电子邮件 matteo.meloni@smart-contact.it 而不是使用问题跟踪器。
致谢
许可证
MIT。请参阅 许可证文件 了解更多信息。