interactive-solutions / zf-log-handler
Interactive Solutions log handler
1.0.0
2019-03-12 12:20 UTC
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' => [], ],
environment
is a string that will be added to the data array being logged, useful for easy filtering if logs contains data from several environmentsdebug
if set to true will log each incoming request and its corresponding response, if set to false it will disable logging of requests/responsesadapters
list of adapters implementing theAdapterInterface
, each adapter'swrite
method with all data to be loggedalwaysLogRoutes
list of route names whose request and corresponding response that should always be logged (event ifdebug
is set to false)
ElasticsearchOptions
Handles configuration for the ElasticsearchAdapter
.
Example config below:
ElasticsearchOptions::class => [ 'host' => 'localhost, 'port' => <port>, 'username' => '', 'password' => '', 'prefix' => 'project-name', ],
host
the elasticsearch hostport
port of the elasticsearch hostusername
username to log onto elasticsearchpassword
password to log onto elasticsearchprefix
the prefix of the index in elasticsearch where data should be logged