razonyang/yii2-log-target-db

Yii2 enhanced database log target

Installs: 3 786

Dependents: 1

Suggesters: 0

Security: 0

Stars: 5

Watchers: 3

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.0 2019-08-21 05:04 UTC

This package is auto-updated.

Last update: 2024-11-21 21:00:10 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads LICENSE

Because the built-in database log target can not figure out the context of same request, especially in the case of concurrency, so that the log is very confusing, it is hard to diagnose errors.

According this problem, what this extension do is that record the request ID via dechex($_SERVER['REQUEST_TIME_FLOAT'] * 1000000).

Installation

composer require razonyang/yii2-log-target-db

Usage

return [
    // console configuration
    'controllerMap' => [
        'migrate' => [
            'migrationPath' => [
                // ...
                '@yii/log/migrations/',
            ],
            'migrationNamespaces' => [
                // ...
                'RazonYang\Yii2\Log\Db\Migration',
            ],
        ],
    ],

    // common/web/console configuration
    'components' => [
        'log' => [
            'targets' => [
                'db' => [
                    'class' => \RazonYang\Yii2\Log\Db\Target::class,
                    'levels' => ['error', 'warning'],
                    'db' => 'db',
                    'logTable' => '{{%log}}',
                ],
            ],
        ],
    ],
];

then:

$ yii migrate