lib/tlogger/tlogger.rb in tlogger-0.21.1 vs lib/tlogger/tlogger.rb in tlogger-0.22.0

- old
+ new

@@ -224,15 +224,15 @@ key = args[0] if is_genabled?(key) and not tag_disabled?(key.to_sym) if block out = Proc.new { block.call } - args = [ format_message(args[0]) ] + args = [ format_message(key) ] else str = args[1] out = Proc.new { str } - args = [ format_message(args[0]) ] + args = [ format_message(key) ] end mtd = mtd.to_s[1..-1].to_sym @logger.send(mtd, *args, &out) end @@ -243,22 +243,50 @@ if is_genabled?(key) and not tag_disabled?(key) if block out = Proc.new { block.call } - args = [ format_message(args[0]) ] + args = [ format_message(key) ] else str = args[1] out = Proc.new { str } - args = [ format_message(args[0]) ] + args = [ format_message(key) ] end msg = out.call if not (msg.nil? or msg.empty?) if not already_shown_or_add(key,msg) mtd = mtd.to_s[1..-1].to_sym @logger.send(mtd, *args, &out) end + end + + end + + elsif [:ifdebug, :iferror, :ifinfo, :ifwarn].include?(mtd) + + cond = args[0] + key = args[1] + + if cond.is_a?(Proc) + cond = cond.call + end + + if is_genabled?(key) and not tag_disabled?(key) and cond + + if block + out = Proc.new { block.call } + args = [ format_message(key) ] + else + str = args[2] + out = Proc.new { str } + args = [ format_message(key) ] + end + + msg = out.call + if not (msg.nil? or msg.empty?) + mtd = mtd.to_s[2..-1].to_sym + @logger.send(mtd, *args, &out) end end elsif @logger.respond_to?(mtd)