2017 © Pedro Peláez
 

library logging-bundle

Logging Bundle

image

vivait/logging-bundle

Logging Bundle

  • Thursday, February 23, 2017
  • by Brunty
  • Repository
  • 2 Watchers
  • 0 Stars
  • 2,311 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 27 % Grown

The README.md

This bundle will add a Monolog processor that adds the client IP, user-agent, kernel environment, user and application name to the extra data of each log line. It also provides an event listener that listens to all events, logging any that implement the LoggableEvent interface., (*1)

Installation

composer require vivait/logging-bundle, (*2)

Include the bundle in your AppKernel:, (*3)

// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Vivait\LoggingBundle\VivaitLoggingBundle(),
        );

        // ...
    }
}

Add the following configuration to your config.yml:, (*4)

vivait_logging:
    application_name: MyAppName
    # Alternatively...
    application_name: '%my_name_parameter%'

Usage

To use the loggable event listener, simply fire any event that implements the LoggableEvent interface, such as the GenericLogEvent that is part of this bundle. To use the extra data, set up a Monolog formatter with the appropriate arguments, or use the provided vivait.logging_bundle.log_formatter service, e.g., (*5)

# config.yml
monolog:
    handlers:
        main:
            type: stream
            path: '%kernel.logs_dir%/%kernel.environment%.log'
            level: debug
            formatter: vivait.logging_bundle.log_formatter

which will display logs in the following format:, (*6)

[%%datetime%%] [%%extra.App%%] [%%extra.Environment%%] [%%extra.User%%] %%channel%%.%%level_name%%: %%message%% [%%extra.IP%%] [%%extra.UA%%] %%context%% %%extra%%

The Versions

23/02 2017

dev-master

9999999-dev

Logging Bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Viva IT

23/02 2017
23/02 2017
23/02 2017
23/02 2017
23/02 2017
23/02 2017
23/02 2017