2017 © Pedro Peláez
 

library monolog

image

adeira/monolog

  • Sunday, July 16, 2017
  • by mrtnzlml
  • Repository
  • 4 Watchers
  • 8 Stars
  • 9,470 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 8 % Grown

The README.md

At this moment I don't have time, energy and money to maintain this project. But it's a shame so if you depend on this project and you want to become a sponsor or develop it further please don't hesitate to contact me. Otherwise, I am not able to guarantee bright future of this repo... :), (*1)

More awesome Monolog for Nette Framework

Build Status, (*2)

This package is extending Kdyby\Monolog to make it more flexible, configurable and awesome., (*3)

Inspiration:, (*4)

Installation

composer require adeira/monolog

And register DI extension in config.neon:, (*5)

extensions:
    monolog: Adeira\Monolog\DI\MonologExtension

Default configuration

Package adeira/monolog brings a lot of formatters and processors by default. This means you can use them only by name. Here is the complete list of defaults:, (*6)

formatters:
    chromePHP: Monolog\Formatter\ChromePHPFormatter
    fluentd: Monolog\Formatter\FluentdFormatter
    gelfMessage: Monolog\Formatter\GelfMessageFormatter
    html: Monolog\Formatter\HtmlFormatter
    json: Monolog\Formatter\JsonFormatter
    line: Monolog\Formatter\LineFormatter
    loggly: Monolog\Formatter\LogglyFormatter
    mongoDB: Monolog\Formatter\MongoDBFormatter
    normalizer: Monolog\Formatter\NormalizerFormatter
    dcalar: Monolog\Formatter\ScalarFormatter
    wildfire: Monolog\Formatter\WildfireFormatter

processors:
    git: Monolog\Processor\GitProcessor
    introspection: Monolog\Processor\IntrospectionProcessor
    memoryPeakUsage: Monolog\Processor\MemoryPeakUsageProcessor
    memoryUsage: Monolog\Processor\MemoryUsageProcessor
    processId: Monolog\Processor\ProcessIdProcessor
    psrLogMessage: Monolog\Processor\PsrLogMessageProcessor
    tag: Monolog\Processor\TagProcessor
    uid: Monolog\Processor\UidProcessor
    web: Monolog\Processor\WebProcessor

handlers:
    errorLog:
        class: Monolog\Handler\ErrorLogHandler

loggers:
    global:
        class: Kdyby\Monolog\Logger # including custom global handlers and processors

You DON'T have to copy paste this into your config file. This is just a quick reference so you can find what you want quickly., (*7)

Overriding configuration

Every formatter and processor uses default configuration if possible. If you want custom configuration, it's easy to override it like this:, (*8)

monolog:
    processors:
        web: Monolog\Processor\WebProcessor(NULL, [
                ip: REMOTE_ADDR,
                userAgent: HTTP_USER_AGENT,
            ])

Changing global logger configuration and adding own loggers

As you already know - this package extends kdyby\monolog. And there is default global logger for whole application. You can configure it by using global name in loggers section. Another loggers will be registered independently (with name or anonymously):, (*9)

monolog:
    handlers:
        slack:
            class: Adeira\Monolog\Handler\SlackHandler(
                %productionMode%,
                %slack.token%,
                %slack.channel%,
                %slack.username%,
                %slack.useAttachment%,
                %slack.iconEmoji%,
                %slack.level%,
                %slack.bubble%,
                %slack.useShortAttachment%,
                %slack.includeContextAndExtra%
            )
    loggers:
        global: # global logger from Kdyby (\Kdyby\Monolog\Logger)
            handlers: [slack]
            processors: [git, introspection, web]
        - class: Custom\Monolog\Loggers\UsersAuditLogger
          handlers: [database]

This way you can setup a lot of loggers with different configuration (handlers, processors, formatter). Your custom loggers are like services in DI container so you can use autowiring to get them. Nothing special. Remember, that it's good idea to extend these custom loggers from \Monolog\Logger or even better from \Kdyby\Monolog\Logger., (*10)

Using Kdyby configuration options

Package adeira/monolog is not playing with Kdyby configuration so you can use it if you want to without changes:, (*11)

monolog:
    hookToTracy: yes
    registerFallback: yes
    usePriorityProcessor: yes

Awesome right? :), (*12)

The Versions