2017 © Pedro Peláez
 

library monolog-ecs

AWS ECS metadata in your log messages

image

chrisguitarguy/monolog-ecs

AWS ECS metadata in your log messages

  • Tuesday, March 13, 2018
  • by chrisguitarguy
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Monolog ECS

A set of monolog processors that add some additional context to Monolog's extra key of the $record., (*1)

More pratically speaking, these allow users to put information in logs about the servers or ECS tasks from which the log messages were generated., (*2)

The values available are pulled from the Container Metadata File and are all the file keys prefixed with aws_ecs_. See below for some examples, (*3)

Installation

composer require chrisguitarguy/monolog-ecs

Usage

use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Chrisguitarguy\MonologEcs\AwsEcsProcessor;

$logger = new Logger('myapp');
// add the processor, `::create()` uses the default dependencies that loads
// metadata from the file and caches it based on the file status
$logger->pushProcessor(AwsEcsProcessor::create());

// now use the various `%extra.aws_ecs_*` values as desired. These are all
// keys from the metadata file lowercased and prefixed with `aws_ecs_`
$handler = new StreamHandler('php://stdout');
$handler->setFormatter(new LineFormatter(
  '[%datetime%] %channel%.%level_name%: %message% (%extra.aws_ecs_taskarn%, %extra.aws_ecs_containerinstancearn%)'
));

$logger->pushHandler($handler);

The above example will include the ECS task's ARN as well as the ARN of the instance on which is the task is running., (*4)

The Versions

13/03 2018

dev-master

9999999-dev

AWS ECS metadata in your log messages

  Sources   Download

MIT

The Requires

  • php ~7.1

 

The Development Requires

monolog aws ecs

13/03 2018

v0.1.0

0.1.0.0

AWS ECS metadata in your log messages

  Sources   Download

MIT

The Requires

  • php ~7.1

 

The Development Requires

monolog aws ecs