module U

U::Log is an opinionated logging library.

The main take is that logs are structured. Too much time is spend formatting logs, they should look nice by default. That's why U::Log uses the lines format by default.

Log everything in development AND production. Logs should be easy to read, grep and parse. Logging something should never fail. Let the system handle the storage. Write to syslog or STDERR. No log levels necessary. Just log whatever you want.

Example:

U.log("Oops !", foo: {}, g: [])
#outputs:
# at=2013-03-07T09:21:39Z pid=3242 app=some-process msg="Oops !" foo={} g=[]

Usage:

U.log(foo: 3, msg: "This")

ctx = U.log_context(encoding_id: Log.id)
ctx.log({})

Attributes

logger[RW]

Default logger that outputs to stderr with the Logfmt format

Public Class Methods

log(*args) click to toggle source

shortcut for U.logger.log

# File lib/u-log.rb, line 103
def log(*args); logger.log(*args); end
log_context(data={}) click to toggle source

shotcut for U.logger.context

# File lib/u-log.rb, line 105
def log_context(data={}); logger.context(data); end