Download the PHP package ecourty/logger-bundle without Composer
On this page you can find all versions of the php package ecourty/logger-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package logger-bundle
Logger Bundle
A Symfony bundle providing a single, reusable Logger service — structured, context-typed
logging with pluggable, per-project parameter processors, instead of hand-rolling the same
Logger/LogParameterProcessorInterface pattern in every project.
Table of Contents
- Requirements
- Installation
- Core Features
- Configuration
- Usage
- Logging
- Defining Log Contexts
- Writing a Custom Parameter Processor
- Message Prefixing
- Enforcing the Pattern with PHPStan
- Development
- License
Requirements
- PHP ≥ 8.3
- Symfony ≥ 7.0
symfony/monolog-bundleregistered in your kernel
Installation
Register the bundle in config/bundles.php (if not using Symfony Flex):
Declare the Monolog channel Logger will write to (the bundle reuses an existing channel,
it never creates one for you — pick any name that fits your project):
Core Features
- 8-level PSR-3 API —
emergencythroughdebug, each call typed with a\BackedEnum $contextand anarray $parameters - Structured context tagging — every message is formatted as
"{$context->value} - {$message}" - Pluggable parameter processors — any value passed in
$parametersis run through the first registeredLogParameterProcessorInterfaceimplementation that supports it; an exception processor ships by default, add your own for any domain type - Reuses an existing Monolog channel — bind
Loggerto any channel you declare yourself; the bundle never touches yourmonolog.yaml - Optional message prefixing — identify the app in aggregated, multi-project logs
- Optional PHPStan enforcement — forbid direct
Psr\Log\LoggerInterfaceinjection so the pattern stays mandatory, not opt-in
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
channel |
string |
(required) | Monolog channel the Logger service writes to. Must be declared under monolog.channels in your own config. |
message_prefix |
string \| null |
null |
Prepended to every message on this channel (e.g. "PMS - "). Disabled when null. |
enable_builtin_processors |
bool |
true |
Register the bundle's own default processors (currently: ThrowableLogParameterProcessor). Set to false to fully replace them. |
Usage
Logging
Autowire Ecourty\LoggerBundle\Service\Logger like any other service:
All 8 PSR-3 levels are available: emergency, alert, critical, error, warning,
notice, info, debug.
Defining Log Contexts
Log contexts are plain \BackedEnum cases — no bundle interface to implement. Define one
enum per domain, alongside that domain's own code:
Writing a Custom Parameter Processor
Implement Ecourty\LoggerBundle\Contract\LogParameterProcessorInterface. It's
auto-registered — no service configuration needed:
Tip: processors are tried in registration order; the first one whose
supports()returnstruewins. The bundledThrowableLogParameterProcessorhandles any\Throwable— setenable_builtin_processors: falseif you want to replace it with your own.
Message Prefixing
Set message_prefix to identify which application a log line came from once several
projects ship to the same aggregator:
Enforcing the Pattern with PHPStan
Register the bundled rule in your own phpstan.neon to forbid injecting
Psr\Log\LoggerInterface directly anywhere in your codebase:
Development
See AGENTS.md for architecture details and contribution guidelines.
License
This bundle is released under the MIT License.
All versions of logger-bundle with dependencies
psr/log Version ^3.0
symfony/config Version ^7.0|^8.0
symfony/dependency-injection Version ^7.0|^8.0
symfony/http-kernel Version ^7.0|^8.0
symfony/monolog-bundle Version ^3.0|^4.0