Download the PHP package roadrunner/psr-logger without Composer
On this page you can find all versions of the php package roadrunner/psr-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download roadrunner/psr-logger
More information about roadrunner/psr-logger
Files in roadrunner/psr-logger
Package psr-logger
Short Description PSR Logger for RoadRunner
License MIT
Homepage https://spiral.dev/
Informations about the package psr-logger
RoadRunner PSR Logger
A PSR-3 compatible logger implementation that integrates with RoadRunner's logging system via RPC calls. This package provides a bridge between PSR-3 logging standards and RoadRunner's centralized logging infrastructure.
RPC Logger vs STDERR Logger
The RPC logger provides several advantages over RoadRunner's built-in STDERR Logger:
- Log Level Control: RPC Logger controls the actual log level sent to RoadRunner server, ensuring proper level filtering and display in RoadRunner logs. Messages from STDERR Logger are processed by RoadRunner with
infolevel. - Context Support: RPC logger preserves structured context data (arrays, objects). STDERR Logger outputs only the message string, ignoring context.
Installation
Usage
Basic Setup
Logging Examples
Log Levels
Supported Log Level Types
The logger accepts log levels in multiple formats:
- String values:
'error','warning','info','debug' - PSR-3 constants:
\Psr\Log\LogLevel::ERROR,\Psr\Log\LogLevel::WARNING - Stringable objects: Any object implementing
\Stringableinterface - BackedEnum values: PHP 8.1+ backed enums with string values
Log Level Mapping
The logger maps PSR-3 log levels to RoadRunner logging methods as follows:
| PSR-3 Level | RoadRunner Method |
|---|---|
| emergency | error |
| alert | error |
| critical | error |
| error | error |
| warning | warning |
| notice | info |
| info | info |
| debug | debug |
Context Handling
The logger supports structured logging with context arrays. Context data is processed by a context processor before being passed to the underlying RoadRunner logger.
Default Context Processor
By default, RpcLogger uses DefaultProcessor which can handle:
- Scalar values (string, int, float, bool)
- Arrays and nested arrays
- Resources (converted to resource type description)
- Objects via built-in object processors:
- DateTimeProcessor: Converts
\DateTimeInterfaceobjects to ISO 8601 format (ATOM) - StringableProcessor: Converts
\Stringableobjects to their string representation - ThrowableProcessor: Converts exceptions/errors to structured arrays with class, message, code, file, line, and trace
- FallbackProcessor: Converts any other objects to arrays with class name and public properties
- DateTimeProcessor: Converts
Extending DefaultProcessor
The recommended approach is to extend DefaultProcessor with custom object processors using the withObjectProcessors() method. This allows you to add your own object handling while keeping all the built-in processors.
[!NOTE] Custom processors added via
withObjectProcessors()are placed before the built-in processors. This means your custom processors take precedence and can override the default behavior for specific object types.
You can also start with an empty processor and add only the processors you need:
Custom Context Processor
For advanced use cases, you can provide a completely custom context processor to the RpcLogger constructor:
All versions of psr-logger with dependencies
ext-json Version *
psr/log Version ^2.0 || ^3.0
roadrunner-php/app-logger Version ^1.2