sergeymakinen / yii2-log-message
此包已被废弃且不再维护。没有建议替代包。
Yii 2 日志目标的日志消息对象
v2.1.0
2018-02-12 10:24 UTC
Requires
- yiisoft/yii2: ~2.0.13
Requires (Dev)
- sergeymakinen/yii2-tests: ^2.0
This package is auto-updated.
Last update: 2022-12-16 00:56:24 UTC
README
包装日志消息并暴露其属性以及当前请求/用户详情到 Yii 2 日志目标的日志消息对象。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
composer require "sergeymakinen/yii2-log-message:^2.0"
或者
"sergeymakinen/yii2-log-message": "^2.0"
将以下内容添加到您的 composer.json
文件的 require 部分中。
使用方法
让我们看一下 Slack 日志目标 的代码片段。
// ... // $message is the sergeymakinen\yii\logmessage\Message class instance $attachment = [ 'fallback' => $this->encode($this->formatMessage($message->message)), 'title' => ucwords($message->level), 'fields' => [], 'text' => "```\n" . $this->encode($message->text . "\n```", 'footer' => static::className(), 'ts' => (int) round($message->timestamp), 'mrkdwn_in' => [ 'fields', 'text', ], ]; if ($message->isConsoleRequest) { $attachment['author_name'] = $message->commandLine; } else { $attachment['author_name'] = $attachment['author_link'] = $message->url; } if (isset($this->colors[$message->message[1]])) { $attachment['color'] = $this->colors[$message->message[1]]; } $this ->insertField($attachment, 'Level', $message->level, true, false) ->insertField($attachment, 'Category', $message->category, true) ->insertField($attachment, 'Prefix', $message->prefix, true) ->insertField($attachment, 'User IP', $message->userIp, true, false) ->insertField($attachment, 'User ID', $message->userId, true, false) ->insertField($attachment, 'Session ID', $message->sessionId, true) ->insertField($attachment, 'Stack Trace', $message->stackTrace, false); // ...