Skip to content

Instantly share code, notes, and snippets.

@adampats
Created April 13, 2017 19:09
Show Gist options
  • Save adampats/0e42b14df965598d5adaf76ecd7500cb to your computer and use it in GitHub Desktop.
Save adampats/0e42b14df965598d5adaf76ecd7500cb to your computer and use it in GitHub Desktop.
stdout within class method
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