lib/logdna.rb in logdna-1.1.1 vs lib/logdna.rb in logdna-1.2.0
- old
+ new
@@ -81,22 +81,23 @@
@level = value
end
def log(msg=nil, opts={})
loggerExist?
- @response = @@client.buffer(msg, default_opts.merge(opts).merge({
+ message = yield if msg.nil? && block_given?
+ @response = @@client.buffer(message, default_opts.merge(opts).merge({
timestamp: (Time.now.to_f * 1000).to_i
}))
'Saved'
end
Resources::LOG_LEVELS.each do |lvl|
name = lvl.downcase
- define_method name do |msg=nil, opts={}|
+ define_method name do |msg=nil, opts={}, &block|
self.log(msg, opts.merge({
level: lvl,
- }))
+ }), &block)
end
define_method "#{name}?" do
return Resources::LOG_LEVELS[self.level] == lvl if self.level.is_a? Numeric
self.level == lvl