Download the PHP package dankkomcg/composite-logger without Composer
On this page you can find all versions of the php package dankkomcg/composite-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dankkomcg/composite-logger
More information about dankkomcg/composite-logger
Files in dankkomcg/composite-logger
Package composite-logger
Short Description Extension of PHP Logger library that allows you to create compositions of loggers.
License MIT
Informations about the package composite-logger
PHP Composite Logger
Composite Logger is an extension of the PHP Logger library that allows you to create compositions of loggers. This enables you to write logs to a file while simultaneously printing them to the console.
Features
- Composite Logging: Combine multiple loggers to handle logging in different outputs.
- Flexible Configuration: Easily configure and extend logger combinations.
Installation
Install the library via Composer:
Usage
Basic example
Here's how you can set up a composite logger to log both to a file and the console:
Configuration
- Loggers Array: Pass an array of loggers to
CompositeLogger
to enable multi-output logging. - Customization: Each logger can be configured individually before being added to the composite.
Logger Types
Composite Logger provides specific types of composite loggers, each designed for different logging strategies. These loggers extend CompositeLogger
and require that all included loggers implement the Logger
interface.
Available Composite Loggers
Default loggers included:
-
SimpleCompositeLogger: This logger allows you to combine multiple loggers in a straightforward manner. It logs messages to all included loggers, making it easy to manage logging across various outputs.
- InverseCompositeLogger: This logger provides an inverse logging mechanism, where it can be configured to exclude certain loggers based on specific conditions or configurations. It's useful for scenarios where you want to prevent logging in certain outputs under specific circumstances.
These are only examples. Check the implementation details.
Implementation Details
-
Extend
CompositeLogger
: BothSimpleCompositeLogger
andInverseCompositeLogger
extend fromCompositeLogger
, ensuring they have the necessary functionality to handle multiple loggers. - Implement the
Logger
Interface: All loggers used within these composites must implement theLogger
interface, ensuring consistency and standard methods for logging operations.
These composite loggers offer flexible and powerful solutions for managing complex logging requirements in your applications.
Testing
To run tests, use PHPUnit:
Requirements
- PHP 7.4 or later.
License
This project is licensed under the MIT License. See the LICENSE file for details.