Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 877 Bytes

README.md

File metadata and controls

38 lines (24 loc) · 877 Bytes

Logger::Metadata

Enhance Ruby logger with support for key-value metadata.

Build Status

Installation

Logger::Metadata is available as a ruby gem.

$ gem install logger-metadata

Usage

require 'logger-metadata'

logger = Logger.new
Logger::Metadata.inject(logger)

logger.metadata(key: 'value') do
  logger.info('message')
end

All log messages within the metadata block will contain the metadata. Nested metadata blocks can be used.

Logger::Metadata will augment the default the default formatter to include metadata and timestamp. For example

[2016-11-30 14:27:19 +0200] Message (key=value)

Rails integration

Rails application is automatically setup by requiring logger/metadata/railtie if Rails is defined.