devgroup/yii2-graylog-target
Composer 安装命令:
composer require devgroup/yii2-graylog-target
包简介
Graylog2 log target for Yii2 framework applications
README 文档
README
Graylog2 log target for Yii2 framework applications
Installation
For installation the yii2-graylog-target library in your projects as composer dependency, run the command:
php composer.phar require "devgroup/yii2-graylog-target:*"
... or just add to composer.json file the following line:
"devgroup/yii2-graylog-target": "*"
Configuration
Configure from config array
'components' => [ 'log' => [ 'grayii' => [ 'transport' => [ 'class' => \Gelf\Transport\HttpTransport::class, 'host' => 'http://graylog2-server.com', 'port' => 12201, ], 'appName' => 'app name', ] ] ]
Available config parameters:
| Param key | Optional | Default value | Description |
|---|---|---|---|
transport |
+ | Gelf\Transport\HttpTransport | Transport config array for publishing a message to Graylog2 server |
publisher |
+ | Gelf\Publisher | Publisher config array |
messageValidator |
+ | Gelf\MessageValidator | Message validator class for publisher |
container |
+ | \Yii::$container | DI container |
version |
+ | 1.1 | GELF spec version |
appName |
+ | ID of the application | Category name for log message |
Usage
-
Sent additional data:
Yii::info([ 'short' => 'Short message or title', // required. alternate usage variant: `Short message or title` (without a key 'short', but first item in array) 'full' => 'Full message', // optional. full message of log. For example, may be a stack trace as string or other detalized message '_field1' => 'value1', // optional. additional field starts with '_' symbol '_field2' => 'value2', // optional. additional field starts with '_' symbol ]);
-
Sent exception:
try { ... running code with harmful bugs... } catch (\Throwable $t) { Yii::warning($t); }
-
Sent short message:
Yii::trace('The short message example'); // or equivalent usage is Yii::trace(['The short message example']);
Tests
Tests was placed int the test directory. Tests can be running by the command:
php composer.phar exec codecept run
Tests with different php versions with docker:
-
PHP v5.6
docker run -it --rm --name php56-for-grayii-tests -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:5.6-cli php vendor/bin/codecept run -
PHP v7.0
docker run -it --rm --name php70-for-grayii-tests -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.0-cli php vendor/bin/codecept run -
HHVM
docker run -it --rm --name hhvm-for-grayii-tests -v "$PWD":/usr/src/myapp -w /usr/src/myapp diegomarangoni/hhvm:cli hhvm vendor/bin/codecept run
统计信息
- 总下载量: 864
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD
- 更新时间: 2016-11-10