class DisqueJockey::Logger
Public Class Methods
new(klass)
click to toggle source
# File lib/disque_jockey/logger.rb, line 6 def initialize(klass) init_color_scheme @logger = Logging.logger[klass] @logger.add_appenders(*log_appenders) @logger.level = :info end
Public Instance Methods
debug(message)
click to toggle source
# File lib/disque_jockey/logger.rb, line 34 def debug(message) @logger.debug(message) end
error(message)
click to toggle source
# File lib/disque_jockey/logger.rb, line 22 def error(message) @logger.error(message) end
fatal(message)
click to toggle source
logging levels
# File lib/disque_jockey/logger.rb, line 18 def fatal(message) @logger.fatal(message) end
info(message)
click to toggle source
# File lib/disque_jockey/logger.rb, line 30 def info(message) @logger.info(message) end
logger()
click to toggle source
# File lib/disque_jockey/logger.rb, line 13 def logger @logger end
warn(message)
click to toggle source
# File lib/disque_jockey/logger.rb, line 26 def warn(message) @logger.warn(message) end
Private Instance Methods
file_appender()
click to toggle source
# File lib/disque_jockey/logger.rb, line 47 def file_appender begin Logging.appenders.file("#{DisqueJockey.configuration.log_path}/#{DisqueJockey.configuration.env}.log", { layout: Logging.layouts.pattern(log_pattern) }) rescue raise "You must provide a valid log path and log file! DisqueJockey by default will log to the current directory /log/environment.log. Make sure that directory exists and the file is writeable!. Configure DisqueJockey's log path before running if you'd like to specify a custom path" end end
init_color_scheme()
click to toggle source
# File lib/disque_jockey/logger.rb, line 67 def init_color_scheme Logging.color_scheme('bright', :levels => { :info => :green, :warn => :yellow, :error => :red, :fatal => [:white, :on_red] }, :date => :blue, :logger => :magenta, :message => :white ) end
log_appenders()
click to toggle source
# File lib/disque_jockey/logger.rb, line 40 def log_appenders appenders = [] appenders << file_appender appenders << stdout_appender if DisqueJockey.configuration.env == 'development' return appenders end
log_pattern()
click to toggle source
# File lib/disque_jockey/logger.rb, line 63 def log_pattern { pattern: '[%d] %-5l %c: %m\n' } end
stdout_appender()
click to toggle source
# File lib/disque_jockey/logger.rb, line 56 def stdout_appender # only add colors to the STDOUT appender to prevent color codes # from getting into the log files and potentially impacting commands # like 'less' and 'more' Logging.appenders.stdout({ layout: Logging.layouts.pattern(log_pattern.merge(color_scheme: 'bright')) }) end