class LoggerLite::Logger
Attributes
handle[RW]
log_location[RW]
Public Class Methods
new(log_location=$stdout, mode="append", startmsg=nil)
click to toggle source
# File lib/logger_lite.rb, line 8 def initialize(log_location=$stdout, mode="append", startmsg=nil) self.log_location = log_location if ! ["write", "append"].include? mode then raise ArgumentError, "#{mode} not supported." end mode = mode == "write" ? "w" : "a" self.handle = File.open(self.log_location, mode) if startmsg != nil data = "[#{Time.now}] - START - #{startmsg}\n" self.handle.write data end end
Public Instance Methods
end_session(data)
click to toggle source
# File lib/logger_lite.rb, line 36 def end_session(data) if data == nil self.handle.close else data = "[#{Time.now}] - END - #{data}\n" self.handle.write(data) self.handle.close end end
error(e)
click to toggle source
# File lib/logger_lite.rb, line 21 def error(e) data = "[#{Time.now}] - ERROR - #{e}\n" self.handle.write(data) end
log(l)
click to toggle source
# File lib/logger_lite.rb, line 26 def log(l) data = "[#{Time.now}] - INFO - #{l}\n" self.handle.write(data) end
warning(w)
click to toggle source
# File lib/logger_lite.rb, line 31 def warning(w) data = "[#{Time.now}] - ERROR - #{w}\n" self.handle.write(data) end