samples/basic.rb in tlogger-0.21.1 vs samples/basic.rb in tlogger-0.22.0

- old
+ new

@@ -30,10 +30,11 @@ log.debug "Outside block. Shall take default tag '#{log.tag}'" log.debug "About to show log message only show once. This can be useful if it is a warning which only print out per run." (0..4).each do |i| + # Show message once only # one time message tie to key # Means if the message is under specific key and already prompted, it will skip # Else it will be printed log.odebug :debug_once, &-> { "this is one time message" } log.oerror :error_once, "One time error" @@ -57,6 +58,16 @@ log.tdebug :another_global, "Now it is my turn to be here" # this line will show up because all is on log.terror :whatever, "Yeah me too!" # this line will show up because all is on log.debug "I'm inherited from key :global so I'm also not visible" # due to on_all_except(:global) this line shall not be printed log.tinfo :global, "Gosh! I've been turned off by default" # due to on_all_except(:global) this line shall not be printed log.twarn :local, "I'm free!" # this line will show up because all is on + +x = 2 +# Log only print if the first parameters is true. +log.ifdebug(x == 2, :ifdebug, "Debug : x == 2!") +log.iferror(x == 2, :iferror, "Err : x == 2!") +log.ifinfo(x == 2, :ifinfo, "Info: x == 2!") +log.ifwarn(x == 2, :ifwarn, "Warn: x == 2!") + +# first param also can be a proc +log.ifdebug Proc.new { x == 2 }, :ifdebug2, "Debug 2 : x == 2!"