A minimal, PSR-3 compliant logging library designed for flexibility and simplicity. It supports multiple log outputs, custom logger configurations, and log level filtering—keeping things as lean as your favorite retro toolkit.
- PSR-3 Compliant: Implements the standard logging interface.
- Custom Logger Implementations: Includes examples like
BuiltinLogger
andNullLogger
. - LogManager: Easily handle and dispatch log messages to one or more logger instances.
- Flexible Configuration: Configure logger behavior, including log level filtering and custom setups.
- Multiple Outputs: Log to multiple destinations without breaking standards.
Install via Composer:
composer require comphp/logging
Create and configure logger instances, then add them to the LogManager:
<?php
require 'vendor/autoload.php';
use Neuron\Logging\LogManager;
use Neuron\Logging\LogLevel;
use Neuron\Logging\Loggers\FileLogger;
// Initialize the log manager
$logManager = new LogManager($container);
$logManager->load(ThirdPartyFileLogger::class, [
'filePath' => __DIR__ . '/logs/app.log',
'supported' => [LogLevel::INFO, LogLevel::WARNING, LogLevel::ERROR],
])
// Dispatch some log messages
$logManager->info("Application started", ['user' => 'Alice']);
$logManager->error("Unhandled exception", ['exception' => 'RuntimeException']);
Additional example scripts are provided in the examples/
directory, demonstrating how to use different logger implementations and configurations.
See CHANGELOG.md for a record of changes.
Contributions are welcome! Please see CONTRIBUTING.md for details on how to help out.
This project is released under a Code of Conduct. Please review CODE_OF_CONDUCT.md for details.
This project is licensed under the MIT License. See the LICENSE file for more information.