Download the PHP package fei/logger-client without Composer
On this page you can find all versions of the php package fei/logger-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package logger-client
Logger Client
Installation
Just add the following requirement to your composer.json file:
Configuration
The logger client needs some options to work properly. The available options that can be passed to the __construct() or setOptions() methods are :
| Option | Description | Type | Possible Values | Default |
|---|---|---|---|---|
| OPTION_BASEURL | This is the server to which send the requests. | string | Any URL, including protocol but excluding path | -- |
| OPTION_FILTER | Minimum notification level required for notifications to be actually sent. | int | Any Notification::LVL_* constant | Notification::LVL_ERROR |
| OPTION_BACKTRACE | Should backtrace be added to notifications before they are sent. | bool | true / false | true |
| OPTION_LOGFILE | File path and name where the Logger will store its own exceptions. | string | Any writeable file path | /tmp/logger.log |
| OPTION_HEADER_AUTHORIZATION | Api Key for authentification | string | Any string value | '' |
Notes: Logger is an alias of Fei\Service\Logger\Client\Logger Notification is an alias of Fei\Service\Logger\Entity\Notification
Usage
Initialization
A Logger client should always be initialized by a dependency injection component, since it requires at least one dependency, which is the transport. Moreover, the BASEURL parameter should also depends on environment.
Pushing a simple notification
Once you have set up the Logger, you can start pushing notifications by calling the notify() method on the Logger:
While its possible to pass more than just the level using the second (array) parameter, it is recommended not to do so. If you want to pass more informations, like a context, please take a look at the following section.
Pushing a Notification instance
The more reliable way to push a notification is to instantiate it by yourself, and then send it through notify(), that will also accept Notification instances:
PSR-3 Adapter
PSR-3 describe an interface for logging purpose to ensure interoperability between systems.
For this end we provide the adapter Fei\Service\Logger\Client\Psr\PsrLoggerAdapter.
It's always possible to set category, namespace and other notification properties with log context:
Manageable Notification properties are flag, namespace, user, server, command, origin, category and env.
Another key of context will be set in Notification context.
All versions of logger-client with dependencies
fei/api-client Version ^1.5.1
fei/logger-common Version ^1.2.3
psr/log Version ^1.1.2