Sha256: 4eb91025b665bc36a9ea8e2f273cd5b11c3890278da4750974a0df6e9678d3c1
Contents?: true
Size: 835 Bytes
Versions: 12
Compression:
Stored size: 835 Bytes
Contents
module Quorum class Logger def initialize(dir) @log_directory = dir @log_file = "quorum.log" end # # Write to log file and exit if exit_status is present. # def log(program, message, exit_status = nil, files = nil) File.open(File.join(@log_directory, @log_file), "a") do |log| log.puts "" log.puts Time.now.to_s + " " + program log.puts message log.puts "" end if exit_status remove_files(files) unless files.nil? exit exit_status.to_i end end private # # Removes instance files. # def remove_files(files) unless Dir.glob(files).empty? `rm #{files}` else log( "remove_files", "Unable to remove #{files}" ) end end end end
Version data entries
12 entries across 7 versions & 1 rubygems