Module: U

Defined in:
lib/u-log.rb,
lib/u-log.rb,
lib/u-log/compat.rb,
lib/u-log/version.rb,
lib/u-log/rack_logger.rb,
lib/u-log/active_record.rb

Overview

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({})

Defined Under Namespace

Modules: Log

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Default logger that outputs to stderr with the Logfmt format



100
101
102
# File 'lib/u-log.rb', line 100

def logger
  @logger
end

Class Method Details

.log(*args) ⇒ Object

shortcut for U.logger.log



103
# File 'lib/u-log.rb', line 103

def log(*args); logger.log(*args); end

.log_context(data = {}) ⇒ Object

shotcut for U.logger.context



105
# File 'lib/u-log.rb', line 105

def log_context(data={}); logger.context(data); end