Skip to content

Instantly share code, notes, and snippets.

@evanphx
Created October 20, 2015 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanphx/cfbfeaeaaa0f0841e0a6 to your computer and use it in GitHub Desktop.
Save evanphx/cfbfeaeaaa0f0841e0a6 to your computer and use it in GitHub Desktop.
Structured Logging
require 'json'
class SLogger
def log(event, opts={})
opts[:event] = event.to_s
emit opts
end
def emit(opts)
$stdout.puts JSON.generate(opts)
end
end
SLog = SLogger.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment