2017 © Pedro Peláez
 

library logger-extra-library

Logger extra useful library

image

inextensodigital/logger-extra-library

Logger extra useful library

  • Wednesday, May 30, 2018
  • by steph_py
  • Repository
  • 21 Watchers
  • 1 Stars
  • 13,276 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 7 Versions
  • 7 % Grown

The README.md

Xeonys Logger Extra

  • Add extra data to logs
  • ELK stack default configuration

Installation

composer.json, (*1)

    "require": {
        "graylog2/gelf-php": "~1.4",
        "inextensodigital/logger-extra-library": "~1.0"
    }

AppKernel, (*2)

$bundles[] = new Xeonys\LoggerExtra\App\Bundle\XeonysLoggerExtraBundle();

config.yml, (*3)

xeonys_logger_extra:
    fields:
        app_name:     app_name #your application name.
        app_env:      %xeonys.logger_extra.app_env%
        server_stack: %xeonys.logger_extra.server_stack%

config_prod.yml, (*4)

imports:
    - { resource: config.yml }
    - { resource: "@XeonysLoggerExtraBundle/Resources/config/monolog_gelf.yml" }

parameters.yml, (*5)

    xeonys.elk.gelf.host: elkdomain.tld
    xeonys.elk.gelf.port: 12201 # in local environment, use a different port, to not polluate elk.
    xeonys.logger_extra.app_env: prod
    xeonys.logger_extra.server_stack: local

Do you deal with long process or subprocess which needs finger crossed passthruLevel reinitialized ?, (*6)

protected function execute(InputInterface $input, OutputInterface $output)
{
    $logger          = $this->getContainer()->get('logger');
    $subprocessScope = $this->getContainer()->get('xeonys.logger_extra.sub_process_scope');

    for ($i = 1; $i <= 10; $i++) {
        $subprocessScope->enter();

        $logger->debug("Begin process($i)");

        try {
            // do something
            $logger->debug("It is ok !!! ($i)");
        } catch (\Exception $e) {
            $logger->critical("Error on ($i)");
        }

        $logger->debug("End process($i)");
    }
}

Imagine we have an error on 3rd $i iteration:, (*7)

Before:, (*8)

You'll have EACH lines logged, because 3rd thrown an error., (*9)

Now:, (*10)

You'll have:, (*11)

[debug] Begin process (3)
[critical] Error in ($3)
[debug] end process (3)

The Versions

30/05 2018

dev-master

9999999-dev

Logger extra useful library

  Sources   Download

The Requires

 

30/05 2018

1.3.1

1.3.1.0

Logger extra useful library

  Sources   Download

The Requires

 

30/05 2018

1.3.0

1.3.0.0

Logger extra useful library

  Sources   Download

The Requires

 

18/07 2017

v1.2.0

1.2.0.0

Logger extra useful library

  Sources   Download

The Requires

  • php >=5.5

 

12/04 2017

v1.1.0

1.1.0.0

Logger extra useful library

  Sources   Download

The Requires

  • php >=5.5

 

09/03 2017

v1.0.1

1.0.1.0

Logger extra useful library

  Sources   Download

The Requires

  • php >=5.5

 

20/09 2016

v1.0.0

1.0.0.0

Logger extra useful library

  Sources   Download

The Requires

  • php >=5.5