Sha256: 04e2be9b9ada60d409cc08df941e7f2e6037d02b2e8f0aaef42373459e529106

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

# StructuredEventLogger

Structured event logger that writes events to both a human readable log and a JSON formatted log

## Installation

Add this line to your application's Gemfile:

    gem 'structured-event-logger'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install structured-event-logger

## Usage

    # Creating an instance
    json_logger = Logger.new('events.log')
    human_readable_logger = Rails.logger
    event_logger = StructuredEventLogger.new(json_logger, human_readable_logger)

    # Basic usage
    event_logger.event('scope', event, field: 'value', other_field, 'other value')

    # Add context per thread/request (e.g. in an around_filter)
    around_filter do
      event_logger.add_context(my_value: 'whatever')
      yield
      event_logger.delete_context  
    end
    
    # later, while processing a request inside that filter
    event_logger.event('scope', 'event', other_value: 'blah') # will also include { my_value: 'whatever' }
  
## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
structured-event-logger-0.0.2 README.md
structured-event-logger-0.0.1 README.md