Skip to content

Commit 6327945

Browse files
author
Stanislav Volovik
committed
Bugfix for blocks; Remove arrays in log, when there\'s only 1 element
1 parent 18d2be9 commit 6327945

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lib/stackify/logger_proxy.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ def initialize logger
77
%w( debug info warn error fatal unknown).each do |level|
88
LoggerProxy.class_eval do
99
define_method level.to_sym do |*args , &block|
10-
msg = message(args, block)
10+
msg = message(*args, &block)
1111
Stackify.logger_client.log(level.downcase, msg, caller)
12-
@logger.send(level.to_sym, args, &block)
12+
@logger.send(level.to_sym, msg, &block)
1313
end
1414
end
1515
end
@@ -24,10 +24,12 @@ def method_missing(name, *args, &block)
2424
private
2525

2626
def message *args, &block
27-
if block
27+
if block_given?
2828
block.call
2929
else
30-
args.flatten[0]
30+
args = args.flatten.compact
31+
args = (args.count == 1 ? args[0] : args)
32+
args.is_a?(Proc) ? args.call : args
3133
end
3234
end
3335

0 commit comments

Comments
 (0)