GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - firespring/hedgelog: An opinionated/strucutred JSON logger for Ruby

BranchesTags
Open more actions menu

Latest commit

 

History

112 Commits
112 Commits

Folders and files

NameName
Last commit message
Last commit date
bin
bin
 
 
config
config
 
 
lib
lib
 
 
spec
spec
 
 
.gitignore
.gitignore
 
 
.rspec
.rspec
 
 
.rubocop.yml
.rubocop.yml
 
 
.ruby-version
.ruby-version
 
 
.simplecov
.simplecov
 
 
.travis.yml
.travis.yml
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Gemfile
Gemfile
 
 
Guardfile
Guardfile
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
hedgelog.gemspec
hedgelog.gemspec
 
 

Repository files navigation

Hedgelog

Gem Version Build Status

This gem provides an opinionated Ruby logger for writing structured JSON logs. It attempts to maintain compatibility with the standard Ruby logger api while extending it with functionality relevant to JSON logging.

Installation

Add this line to your application's Gemfile:

gem 'hedgelog'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hedgelog

Basic Usage

require 'hedgelog'

# Logging defaults to STDOUT or you can pass a file path to .new
logger = Hedgelog::Channel.new

logger.level = :info

logger.debug "Foo"
# No Output

logger.info "Foo"
=> {"message":"FOO","timestamp":"2015-07-15T12:03:08.257356","level_name":"info","level":1}

logger.info "FOO", sample: 'data'
=> {"context": {"sample":"data"},"message":"FOO","timestamp":"2015-07-15T12:05:02.302202","level_name":"info","level":1}

# It also supports logging as a block with extra data
logger.info { ["FOO", {sample: 'data'}] }
=> {"context", {"sample":"data"},"message":"FOO","timestamp":"2015-07-15T12:06:20.026807","level_name":"info","level":1}

Context

Hedgelog allows adding additional context to an instance of a logger that will get output with each log message

logger[:request_id] = 1234
=> 1234
logger.info "FOO"
=> {"request_id":1234,"message":"FOO","timestamp":"2015-07-15T12:09:33.129984","level_name":"info","level":1}

Channels

One of the primary features of Hedgelog is the usage of channels.

Channels can have their own context separate from the main loggers context. This allows including additional information for all log messages from a portion of your application.

channel = logger.channel(:database)
channel.info "FOO"
=> {"channel":"database","message":"FOO","timestamp":"2015-07-15T12:12:39.147210","level_name":"info","level":1}

# The channel does not effect the primary instance of the logger
logger.info "FOO"
=>{"message":"FOO","timestamp":"2015-07-15T12:13:31.132059","level_name":"info","level":1}

The channel instances conform to the same interface as Hedgelog. Therefore they can be passed in as standard Ruby loggers to gems that take an instance of Ruby logger for input.

DataMapper.logger = logger.channel(:database)

Scrubbing

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/firespring/hedgelog.

For details on the pull request process please see our contributing documentation

About

An opinionated/strucutred JSON logger for Ruby

Topics

json-loggingrubyruby-logger

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

1 star

Watchers

36 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.