class Logger
Extensions to the built in Ruby logger.
If you want to use the default log formatter as defined in the Ruby core, then you will need to set the formatter for the logger as in:
logger.formatter = Formatter.new
You can then specify the datetime format, for example:
logger.datetime_format = "%Y-%m-%d"
Note: This logger is deprecated in favor of ActiveSupport::BufferedLogger
Public Instance Methods
datetime_format()
click to toggle source
Get the logging datetime format. Returns nil if the formatter does not support datetime formatting.
# File lib/inactive_support/clean_logger.rb, line 45 def datetime_format formatter.datetime_format if formatter.respond_to?(:datetime_format) end
Also aliased as: old_datetime_format
datetime_format=(datetime_format)
click to toggle source
Logging date-time format (string passed to strftime
). Ignored if the formatter does not respond to datetime_format
=.
# File lib/inactive_support/clean_logger.rb, line 38 def datetime_format=(datetime_format) formatter.datetime_format = datetime_format if formatter.respond_to?(:datetime_format=) end
Also aliased as: old_datetime_format=
formatter()
click to toggle source
Get the current formatter. The default formatter is a SimpleFormatter
which only displays the log message
# File lib/inactive_support/clean_logger.rb, line 52 def formatter @formatter ||= SimpleFormatter.new end
Also aliased as: old_formatter
silence(temporary_level = Logger::ERROR) { |self| ... }
click to toggle source
Silences the logger for the duration of the block.
# File lib/inactive_support/clean_logger.rb, line 22 def silence(temporary_level = Logger::ERROR) if silencer begin old_logger_level, self.level = level, temporary_level yield self ensure self.level = old_logger_level end else yield self end end
Private Instance Methods
format_datetime(datetime)
click to toggle source
# File lib/inactive_support/clean_logger.rb, line 122 def format_datetime(datetime) datetime end
Also aliased as: old_format_datetime
format_message(severity, timestamp, progname, msg)
click to toggle source
# File lib/inactive_support/clean_logger.rb, line 110 def format_message(severity, timestamp, progname, msg) formatter.call(severity, timestamp, progname, msg) end
Also aliased as: old_format_message
msg2str(msg)
click to toggle source
# File lib/inactive_support/clean_logger.rb, line 125 def msg2str(msg) msg end
Also aliased as: old_msg2str