All Projects → nikolaposa → Monolog Factory

nikolaposa / Monolog Factory

Licence: mit
🏭 Configuration-based Monolog logger factory.

Labels

Projects that are alternatives of or similar to Monolog Factory

typeorm-factory
Typeorm factory that makes testing easier
Stars: ✭ 28 (+27.27%)
Mutual labels:  factory
SimpleObjectPool
Simple thread-safe object pool in Objective-C
Stars: ✭ 13 (-40.91%)
Mutual labels:  factory
angular-footballdata-api-factory
AngularJS Factory for the football-data.org JSON REST API
Stars: ✭ 48 (+118.18%)
Mutual labels:  factory
factoria
Simplistic model factory for Node/JavaScript
Stars: ✭ 49 (+122.73%)
Mutual labels:  factory
ViewControllersFactory
Instantiate your ViewControllers easily with this small factory class
Stars: ✭ 26 (+18.18%)
Mutual labels:  factory
metamorphic
A factory contract for creating metamorphic (i.e. redeployable) contracts.
Stars: ✭ 167 (+659.09%)
Mutual labels:  factory
angular-github-api-factory
AngularJS Factory for GitHub v3 JSON REST API requests
Stars: ✭ 13 (-40.91%)
Mutual labels:  factory
Qr Code
QR Code Generator
Stars: ✭ 3,519 (+15895.45%)
Mutual labels:  factory
mimesis-factory
Mimesis integration with factory_boy
Stars: ✭ 42 (+90.91%)
Mutual labels:  factory
movie-booking
An example for booking movie seat, combined of Android Data Binding, State Design Pattern and Multibinding + Autofactory. iOS version is: https://github.com/lizhiquan/MovieBooking
Stars: ✭ 80 (+263.64%)
Mutual labels:  factory
UA-IIoT-StarterKit
Samples and tutorials to illustrate how to build OPC UA PubSub applications.
Stars: ✭ 55 (+150%)
Mutual labels:  factory
SteroidsDI
Advanced Dependency Injection to use every day.
Stars: ✭ 15 (-31.82%)
Mutual labels:  factory
gioc
golang ioc framework
Stars: ✭ 33 (+50%)
Mutual labels:  factory
faker
Random fake data and struct generator for Go.
Stars: ✭ 67 (+204.55%)
Mutual labels:  factory
k-redux-factory
Factory of Redux reducers and their associated actions and selectors.
Stars: ✭ 18 (-18.18%)
Mutual labels:  factory
angular-youtube-api-factory
AngularJS Factory for Youtube JSON REST API requests
Stars: ✭ 21 (-4.55%)
Mutual labels:  factory
dotnet-design-patterns-samples
The samples of .NET design patterns
Stars: ✭ 25 (+13.64%)
Mutual labels:  factory
Route Composer
Protocol oriented, Cocoa UI abstractions based library that helps to handle view controllers composition, navigation and deep linking tasks in the iOS application. Can be used as the universal replacement for the Coordinator pattern.
Stars: ✭ 362 (+1545.45%)
Mutual labels:  factory
Stampit
OOP is better with stamps: Composable object factories.
Stars: ✭ 3,021 (+13631.82%)
Mutual labels:  factory
Laravel-Ecommerce-API
Lite E-Commerce API
Stars: ✭ 32 (+45.45%)
Mutual labels:  factory

Monolog Factory

Build Status Code Quality Code Coverage Latest Version PDS Skeleton

Monolog Factory that allows configuration-based creation of Logger objects.

In addition to the generic factory, this package features one to be used with PSR-11 dependency injection containers.

Installation

The preferred method of installation is via Composer. Run the following command to install the latest version of a package and add it to your project's composer.json:

composer require nikolaposa/monolog-factory

Usage

Generic factory

use Monolog\Formatter\HtmlFormatter;
use Monolog\Handler\NativeMailerHandler;
use Monolog\Logger;
use Monolog\Processor\PsrLogMessageProcessor;
use MonologFactory\LoggerFactory;

$loggerFactory = new LoggerFactory();

$logger = $loggerFactory->create('my_logger', [
    'handlers' => [
        [
            'name' => NativeMailerHandler::class,
            'params' => [
                'to' => '[email protected]',
                'subject' => 'Test',
                'from' => '[email protected]',
                'level' => Logger::ALERT,
            ],
            'formatter' => [
                'name' => HtmlFormatter::class,
            ],
        ],
    ],
    'processors' => [
        [
            'name' => PsrLogMessageProcessor::class,
        ],
    ],
]);

DI container factory configuration

use Monolog\Formatter\HtmlFormatter;
use Monolog\Handler\BufferHandler;
use Monolog\Handler\NativeMailerHandler;
use Monolog\Logger;
use Monolog\Processor\PsrLogMessageProcessor;
use MonologFactory\DiContainerLoggerFactory;

return [
    'logger' => [
        'logger1' => [
            'name' => 'logger1',
            'handlers' => [
                [
                    'name' => NativeMailerHandler::class,
                    'params' => [
                        'to' => '[email protected]',
                        'subject' => 'Test',
                        'from' => '[email protected]',
                        'level' => Logger::ALERT,
                    ],
                    'formatter' => [
                        'name' => HtmlFormatter::class,
                    ],
                ],
            ],
            'processors' => [
                [
                    'name' => PsrLogMessageProcessor::class,
                ],
            ],
        ],
        'logger2' => [
            'name' => 'logger2',
            'handlers' => [
                [
                    'name' => BufferHandler::class,
                    'params' => [
                        'handler' => [
                            '__class__' => NativeMailerHandler::class,
                            'to' => '[email protected]',
                            'subject' => 'Test',
                            'from' => '[email protected]',
                        ],
                        'buffer_limit' => 5,
                    ],
                    'processors' => [
                        [
                            'name' => MemoryUsageProcessor::class,
                        ],
                    ],
                ],
            ],
            'processors' => [
                [
                    'name' => PsrLogMessageProcessor::class,
                ],
            ],
        ],
    ],
    'di' => [
        'factories' => [
            'Logger1' => new DiContainerLoggerFactory('logger1'),
            //... or more preferred/optimal way:
            'Logger2' => [DiContainerLoggerFactory::class, 'logger2'],
        ],
    ],
];

See more examples.

Credits

License

Released under MIT License - see the License File for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].