lib/pliny/log.rb in pliny-0.7.3 vs lib/pliny/log.rb in pliny-0.8.0
- old
+ new
@@ -1,18 +1,26 @@
module Pliny
module Log
def log(data, &block)
- data = log_context.merge(local_context.merge(data))
+ data = default_context.merge(log_context.merge(local_context.merge(data)))
log_to_stream(stdout || $stdout, data, &block)
end
def context(data, &block)
old = local_context
self.local_context = old.merge(data)
res = block.call
ensure
self.local_context = old
res
+ end
+
+ def default_context=(default_context)
+ @default_context = default_context
+ end
+
+ def default_context
+ @default_context || {}
end
def stdout=(stream)
@stdout = stream
end