interactive-solutions / zf-log-handler
Interactive Solutions log handler
Installs: 59
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 3
pkg:composer/interactive-solutions/zf-log-handler
Requires
- php: ^7.0.0
- ruflin/elastica: ~6.1
README
Utility library to log exception (with stacktrace) and requests/response details to configured adapters.
Request duration
The duration will be part of the data sent to each adapter if the constant START_TIME is
defined. If you wish to log the duration you should define('START_TIME', microtime(true))
before the application is bootstrapped.
Adapters
All adapters must implement the AdapterInterface, the only provided adapter built into
this library is ElasticsearchAdapter which logs data to elasticsearch.
Options
LogHandlerOptions
Handles general configuration of this library.
Example config below:
LogHandlerOptions::class => [
    'environment'     => 'dev',
    'debug'           => true,
    'adapters'        => [
        ElasticsearchAdapter::class,
    ],
    'alwaysLogRoutes' => [],
],
- environmentis a string that will be added to the data array being logged, useful for easy filtering if logs contains data from several environments
- debugif set to true will log each incoming request and its corresponding response, if set to false it will disable logging of requests/responses
- adapterslist of adapters implementing the- AdapterInterface, each adapter's- writemethod with all data to be logged
- alwaysLogRouteslist of route names whose request and corresponding response that should always be logged (event if- debugis set to false)
ElasticsearchOptions
Handles configuration for the ElasticsearchAdapter.
Example config below:
ElasticsearchOptions::class => [
    'host'     => 'localhost,
    'port'     => <port>,
    'username' => '',
    'password' => '',
    'prefix'   => 'project-name',
],
- hostthe elasticsearch host
- portport of the elasticsearch host
- usernameusername to log onto elasticsearch
- passwordpassword to log onto elasticsearch
- prefixthe prefix of the index in elasticsearch where data should be logged