devgroup / yii2-graylog-target
Graylog2 log target for Yii2 framework applications
Requires
- php: >=5.5
- graylog2/gelf-php: ~1.5
- psr/log: ~1.0.2
- yiisoft/yii2: ~2.0
Requires (Dev)
- codeception/codeception: ^2.2
This package is not auto-updated.
Last update: 2024-10-27 01:55:19 UTC
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:
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