class Rakie::Log
Constants
- LEVEL_DEBUG
- LEVEL_ERROR
- LEVEL_INFO
Attributes
level[RW]
out[RW]
Public Class Methods
debug(message, who=nil)
click to toggle source
# File lib/rakie/log.rb, line 75 def self.debug(message, who=nil) unless self.instance.level_debug? return end if who message = "#{who}: #{message}" end level = self.instance.level_text(LEVEL_DEBUG) self.instance.out.print("[#{Time.now.to_s}][#{level}] #{message}\n") end
error(message, who=nil)
click to toggle source
# File lib/rakie/log.rb, line 62 def self.error(message, who=nil) unless self.instance.level_error? return end if who message = "#{who}: #{message}" end level = self.instance.level_text(LEVEL_ERROR) self.instance.out.write("[#{Time.now.to_s}][#{level}] #{message}\n") end
info(message, who=nil)
click to toggle source
# File lib/rakie/log.rb, line 49 def self.info(message, who=nil) unless self.instance.level_info? return end if who message = "#{who}: #{message}" end level = self.instance.level_text(LEVEL_INFO) self.instance.out.write("[#{Time.now.to_s}][#{level}] #{message}\n") end
instance()
click to toggle source
# File lib/rakie/log.rb, line 45 def self.instance @instance ||= Log.new end
level()
click to toggle source
# File lib/rakie/log.rb, line 88 def self.level self.instance.level end
level=(level)
click to toggle source
# File lib/rakie/log.rb, line 92 def self.level=(level) self.instance.level = level end
new()
click to toggle source
# File lib/rakie/log.rb, line 11 def initialize @level = Rakie.current_mode == Rakie::MODE_DEV ? LEVEL_DEBUG : LEVEL_ERROR @out = STDOUT end
Public Instance Methods
level_debug?()
click to toggle source
# File lib/rakie/log.rb, line 41 def level_debug? @level >= LEVEL_DEBUG end
level_error?()
click to toggle source
# File lib/rakie/log.rb, line 37 def level_error? @level >= LEVEL_ERROR end
level_info?()
click to toggle source
# File lib/rakie/log.rb, line 33 def level_info? @level >= LEVEL_INFO end
level_text(level=nil)
click to toggle source
# File lib/rakie/log.rb, line 16 def level_text(level=nil) unless level level = @level end case level when LEVEL_INFO return "INFO" when LEVEL_ERROR return "ERROR" when LEVEL_DEBUG return "DEBUG" end end