Inspired by the buffered logger idea by Ezra

Namespace
Methods
A
C
F
L
N
O
R
S
Included Modules
Constants
MAX_BUFFER_SIZE = 1000
 
Attributes
[R] auto_flushing
Class Public methods
new(log, level = DEBUG)
# File activesupport/lib/active_support/buffered_logger.rb, line 47
    def initialize(log, level = DEBUG)
      @log_dest      = log

      unless log.respond_to?(:write)
        unless File.exist?(File.dirname(log))
          ActiveSupport::Deprecation.warn("Automatic directory creation for '#{log}' is deprecated.  Please make sure the directory for your log file exists before creating the logger.
")
          FileUtils.mkdir_p(File.dirname(log))
        end
      end

      @log = open_logfile log
      self.level = level
    end
silencer

Set to false to disable the silencer

# File activesupport/lib/active_support/buffered_logger.rb, line 26
cattr_accessor :silencer
Instance Public methods
add(severity, message = nil, progname = nil, &block)
# File activesupport/lib/active_support/buffered_logger.rb, line 79
def add(severity, message = nil, progname = nil, &block)
  @log.add(severity, message, progname, &block)
end
auto_flushing=(period)

Set the auto-flush period. Set to true to flush after every log message, to an integer to flush every N messages, or to false, nil, or zero to never auto-flush. If you turn auto-flushing off, be sure to regularly flush the log yourself – it will eat up memory until you do.

# File activesupport/lib/active_support/buffered_logger.rb, line 103
def auto_flushing=(period)
end
close()
# File activesupport/lib/active_support/buffered_logger.rb, line 116
def close
  @log.close
end
flush()
# File activesupport/lib/active_support/buffered_logger.rb, line 107
def flush
end
level()
# File activesupport/lib/active_support/buffered_logger.rb, line 71
def level
  @log.level
end
level=(l)
# File activesupport/lib/active_support/buffered_logger.rb, line 75
def level=(l)
  @log.level = l
end
open_log(log, mode)
# File activesupport/lib/active_support/buffered_logger.rb, line 63
def open_log(log, mode)
  open(log, mode).tap do |open_log|
    open_log.set_encoding(Encoding::BINARY) if open_log.respond_to?(:set_encoding)
    open_log.sync = true
  end
end
respond_to?(method, include_private = false)
# File activesupport/lib/active_support/buffered_logger.rb, line 111
def respond_to?(method, include_private = false)
  return false if method.to_s == "flush"
  super
end
silence(temporary_level = ERROR)

Silences the logger for the duration of the block.

# File activesupport/lib/active_support/buffered_logger.rb, line 30
def silence(temporary_level = ERROR)
  if silencer
    begin
      logger = self.class.new @log_dest.dup, temporary_level
      yield logger
    ensure
      logger.close
    end
  else
    yield self
  end
end