Last active
June 5, 2018 13:58
-
-
Save ksss/05e6e0497a50a91ff92432577ec3e0ce to your computer and use it in GitHub Desktop.
The logger that does not execute expressions inside depending on conditions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'logger' | |
case ARGV[0] | |
when "stdout" | |
log = Logger.new(STDOUT) | |
else | |
log = nil | |
end | |
log&.debug("time: #{Time.now}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby log.rb stdout #=> time: time: 2018-06-05... | |
ruby log.rb #=> (nothing) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment