Created
April 13, 2017 19:09
-
-
Save adampats/0e42b14df965598d5adaf76ecd7500cb to your computer and use it in GitHub Desktop.
stdout within class method
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
require 'ruby_expect' | |
require 'timeout' | |
require 'pry' | |
@verbose = true | |
log_name = "#{Time.now.utc.strftime('%Y-%m-%d-%H%M%SZ')}-#{@prog_name}.log" | |
timeout_seconds = '600' | |
class Log | |
def initialize(log_path) | |
@log = Logger.new(log_path) | |
end | |
def add(msg, sev = Logger::INFO) | |
if @verbose | |
puts msg | |
STDOUT.flush | |
end | |
@log.add(sev, msg, @prog_name) | |
return true | |
end | |
end | |
log = Log.new(log_name) | |
log.add("Initialized") | |
# some more code | |
puts "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment