2017 © Pedro Peláez
 

library context-logger

A PSR-3 compliant logger decorator which allows context metadata to be built up.

image

tomphp/context-logger

A PSR-3 compliant logger decorator which allows context metadata to be built up.

  • Thursday, November 24, 2016
  • by tomphp
  • Repository
  • 1 Watchers
  • 13 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Context Logger

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

A PSR-3 compliant logger decorator which allows context metadata to be built up., (*2)

Installation

$ composer require tomphp/context-logger

Usage

<?php

use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use TomPHP\ContextLogger;

$monolog = new Logger('name');
$monolog->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));

$log = new ContextLogger($monolog);

$log->addContext('correlation_id', uniqid());

$log->error('There was an error');

Setting the Context

An original context can be set by providing an array as the second argument to the constructor:, (*3)

$log = new ContextLogger($monolog, ['correlation_id' => uniqid()]);

The context can be added to or modified by the addContext(string $name, $value) method., (*4)

The context can also be added to/modified by providing an array to the $context parameter of any of the PSR-3 LoggerInterface methods., (*5)

Removing Context

You can remove a item from the context by using the removeContext(string $name) method., (*6)

The Versions

24/11 2016

dev-master

9999999-dev https://github.com/tomphp/php-context-logger

A PSR-3 compliant logger decorator which allows context metadata to be built up.

  Sources   Download

MIT

The Requires

 

The Development Requires

logger log psr-3 psr3

24/11 2016

v1.1.0

1.1.0.0 https://github.com/tomphp/php-context-logger

A PSR-3 compliant logger decorator which allows context metadata to be built up.

  Sources   Download

MIT

The Requires

 

The Development Requires

logger log psr-3 psr3

20/11 2016

v1.0.0

1.0.0.0 https://github.com/tomphp/php-context-logger

A PSR-7 compliant logger decorator which allows context metadata to be built up.

  Sources   Download

MIT

The Requires

 

The Development Requires

logger psr-7 log psr7