Class Logger
In: vendor/rails/activesupport/lib/active_support/core_ext/logger.rb
vendor/rails/activesupport/lib/active_support/clean_logger.rb
Parent: Object

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

Methods

Classes and Modules

Class Logger::Formatter
Class Logger::SimpleFormatter

External Aliases

datetime_format= -> old_datetime_format=
datetime_format -> old_datetime_format
formatter -> old_formatter
format_message -> old_format_message
format_datetime -> old_format_datetime
msg2str -> old_msg2str

Public Class methods

[Source]

   # File vendor/rails/activesupport/lib/active_support/core_ext/logger.rb, line 4
4:   def self.define_around_helper(level)
5:     module_eval "def around_\#{level}(before_message, after_message, &block)\nself.\#{level}(before_message)\nreturn_value = block.call(self)\nself.\#{level}(after_message)\nreturn return_value\nend\n"
6:   end

Public Instance methods

Get the logging datetime format. Returns nil if the formatter does not support datetime formatting.

[Source]

    # File vendor/rails/activesupport/lib/active_support/clean_logger.rb, line 45
45:   def datetime_format
46:     formatter.datetime_format if formatter.respond_to?(:datetime_format)
47:   end

Logging date-time format (string passed to strftime). Ignored if the formatter does not respond to datetime_format=.

[Source]

    # File vendor/rails/activesupport/lib/active_support/clean_logger.rb, line 38
38:   def datetime_format=(datetime_format)
39:     formatter.datetime_format = datetime_format if formatter.respond_to?(:datetime_format=)
40:   end

Get the current formatter. The default formatter is a SimpleFormatter which only displays the log message

[Source]

    # File vendor/rails/activesupport/lib/active_support/clean_logger.rb, line 52
52:   def formatter
53:     @formatter ||= SimpleFormatter.new
54:   end

Silences the logger for the duration of the block.

[Source]

    # File vendor/rails/activesupport/lib/active_support/clean_logger.rb, line 22
22:   def silence(temporary_level = Logger::ERROR)
23:     if silencer
24:       begin
25:         old_logger_level, self.level = level, temporary_level
26:         yield self
27:       ensure
28:         self.level = old_logger_level
29:       end
30:     else
31:       yield self
32:     end
33:   end

[Validate]