https://github.com/mimmi20/monolog-laminas-factory
library which allows configuration-based creation of Monolog to Laminas bridge
https://github.com/mimmi20/monolog-laminas-factory
laminas-log logger logging monolog php74
Last synced: about 2 months ago
JSON representation
library which allows configuration-based creation of Monolog to Laminas bridge
- Host: GitHub
- URL: https://github.com/mimmi20/monolog-laminas-factory
- Owner: mimmi20
- License: mit
- Archived: true
- Created: 2021-06-12T09:52:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-18T21:44:32.000Z (about 3 years ago)
- Last Synced: 2025-01-05T21:04:34.534Z (11 months ago)
- Topics: laminas-log, logger, logging, monolog, php74
- Language: PHP
- Homepage:
- Size: 789 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# monolog-laminas-factory
[Monolog](https://github.com/Seldaek/monolog) Factories for Laminas and Mezzio
This library was inspired by [psr11-monolog](https://gitlab.com/blazon/psr11-monolog)
and [monolog-factory](https://github.com/nikolaposa/monolog-factory).
[](https://packagist.org/packages/mimmi20/monolog-laminas-factory)
[](https://packagist.org/packages/mimmi20/monolog-laminas-factory)
[](https://packagist.org/packages/mimmi20/monolog-laminas-factory)
## Code Status
[](https://codecov.io/gh/mimmi20/monolog-laminas-factory)
[](http://isitmaintained.com/project/mimmi20/monolog-laminas-factory "Average time to resolve an issue")
[](http://isitmaintained.com/project/mimmi20/monolog-laminas-factory "Percentage of issues still open")
## Table of Contents
- [Installation](#installation)
- [Usage with Laminas and Mezzio](#usage-with-laminas-and-mezzio)
- [Configuration](#configuration)
- [Minimal Configuration](#minimal-configuration)
- [Full Configuration](#full-configuration)
## Installation
Run
```shell
composer require mimmi20/monolog-laminas-factory
```
## Usage with Laminas and Mezzio
You'll need to add configuration and register the services you'd like to use. There are number of ways to do that
but the recommended way is to create a new config file `config/autoload/logger.config.php`
## Configuration
config/autoload/monolog.global.php
```php
[
\Laminas\Log\Logger::class => [
'name' => 'name',
'exceptionhandler' => false,
'errorhandler' => false,
'shutdownhandler' => false,
'writers' => [], // Writers for Laminas Log
'processors' => [], // Processors for Laminas Log
'handlers' => [ // Handlers for Monolog
// At the bare minimum you must include a default handler config.
// Otherwise log entries will be sent to the void.
'default' => [
'type' => 'stream',
'enabled' => true,
'options' => [
'stream' => '/var/log/some-log-file.txt',
],
],
// Another Handler
'myOtherHandler' => [
'type' => 'stream',
'enabled' => false,
'options' => [
'stream' => '/var/log/someother-log-file.txt',
],
],
],
'monolog_processors' => [], // Processors for Monolog
],
],
];
```
## Minimal Configuration
A minimal configuration would consist of at least one default handler and one named service.
Please note that if you don't specify a default handler a NullHandler will be used
when you wire up the default logger.
### Minimal Example (using Mezzio for the example)
```php
[
\Laminas\Log\Logger::class => [
'name' => 'name',
'handlers' => [
'default' => [
'type' => 'stream',
'options' => [
'stream' => '/var/log/some-log-file.txt',
],
],
],
],
],
];
```
## Full Configuration
### Full Example
```php
[
\Laminas\Log\Logger::class => [
'name' => 'name',
'handlers' => [
'default' => [
// A Handler type or pre-configured service from the container
'type' => 'stream',
// Handler specific options. See handlers below
'options' => [
'stream' => '/tmp/log_one.txt',
// Optional: Formatter for the handler.
'formatter' => [
'type' => 'line',
// formatter specific options. See formatters below
'options' => [],
],
// Optional: Processor for the handler
'processors' => [
[
// A processor type or pre-configured service from the container
'type' => 'psrLogMessage',
// processor specific options. See processors below
'options' => [],
],
],
],
],
],
// Processors for Monolog/Logger
'monolog_processors' => [
// Array Keys are the names used for the processors
'processorOne' => [
// A processor type or pre-configured service from the container
'type' => 'psrLogMessage',
// processor specific options. See processors below
'options' => [],
],
],
],
],
];
```
## License
This package is licensed using the MIT License.
Please have a look at [`LICENSE.md`](LICENSE.md).