# class ActiveSupport::BufferedLogger

Inspired by the buffered logger idea by Ezra

### Constants

MAX_BUFFER_SIZE

### Attributes

auto_flushing[R]

### Public Class Methods

new(log, level = DEBUG) click to toggle source

    # File lib/active_support/buffered_logger.rb, line 47
        def initialize(log, level = DEBUG)
          @level         = level
          @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
        end

silencer() click to toggle source

Set to false to disable the silencer

    # File lib/active_support/buffered_logger.rb, line 26
    cattr_accessor :silencer

### Public Instance Methods

add(severity, message = nil, progname = nil, &block) click to toggle source

    # File 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) click to toggle source

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 lib/active_support/buffered_logger.rb, line 103
    def auto_flushing=(period)
    end

close() click to toggle source

    # File lib/active_support/buffered_logger.rb, line 116
    def close
      @log.close
    end

flush() click to toggle source

    # File lib/active_support/buffered_logger.rb, line 107
    def flush
    end

level() click to toggle source

    # File lib/active_support/buffered_logger.rb, line 71
    def level
      @log.level
    end

level=(l) click to toggle source

    # File lib/active_support/buffered_logger.rb, line 75
    def level=(l)
      @log.level = l
    end

open_log(log, mode) click to toggle source

    # File 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) click to toggle source

    # File 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) { |logger| ... } click to toggle source

Silences the logger for the duration of the block.

    # File 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