Download the PHP package integration-eye/logging-probe without Composer
On this page you can find all versions of the php package integration-eye/logging-probe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download integration-eye/logging-probe
More information about integration-eye/logging-probe
Files in integration-eye/logging-probe
Package logging-probe
Short Description Integration Eye™ Logging Probe
License MIT
Informations about the package logging-probe
Integration Eye Logging Probe
This library is implementation of PSR-3 Logger Interface sending log messages and exceptions to Integration Eye instance.
Installation
This library is available in Packagist, so you can install it using Composer:
For usage of this library, you need to provide implementation of Client
interface.
If you install symfony/http-client
package, default implementation will be provided.
For more information about custom Client
implementation see Client.
Simple Usage
There is Logger::fromDsn($dsn)
factory function for simple instantiation of Logger
.
Logger implements PSR-3 Logger Interface so you can use is as follows:
You can pass internal flags like @principal
into context, and it will be used as metadata.
For more information about providing @principal
, see PrincipalProvider.
Advanced Usage
Logger is composed of MessageFactory
instance and Client
implementation.
Here is an example of creating Logger
manually without Logger::fromDsn($dsn)
factory method.
Extensions
Client
Client
interface consist of single method sendMessage(Configuration $configuration, array $payload): void
which purpose is to send POST request to configured endpoint.
Optional default implementation is using symfony/http-client
, but you can provide your own, if it is not what you need.
Here is a simplified example of existing client for testing purposes.
PrincipalProvider
To send @principal
metadata with your logs, you can provide implementation of PrincipalProvider
. It has single method getPrincipal(): ?string
which you can override.
Here is an example of custom implementation:
If you want, you can use built-in DefaultPrincipalProvider
for static resolution of principal.
Mapper
You can provide implementations of Mapper
interface for simplifying your logging. It consists of two methods supports(string $key, $value): bool
and map(string $key, $value): array
.
Here is a simplified example of existing mapper for JsonSerializable
objects:
This library provides some built-in mappers:
DateTimeMapper
for formattingDateTime
objectsJsonMapper
for serializingJsonSerializable
objectsExceptionMapper
for serializingThrowable
objects and providing@exception
,@stackTrace
metadata
When you use Logger::fromDsn($dsn)
or MessageFactory::instance($configuration)
, all built-in mappers will be automatically registered with their default configuration.