Parent

Included Modules

Class Index [+]

Quicksearch

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
47:     def initialize(log, level = DEBUG)
48:       @log_dest      = log
49: 
50:       unless log.respond_to?(:write)
51:         unless File.exist?(File.dirname(log))
52:           ActiveSupport::Deprecation.warn(Automatic directory creation for '#{log}' is deprecated.  Please make sure the directory for your log file exists before creating the logger.)
53:           FileUtils.mkdir_p(File.dirname(log))
54:         end
55:       end
56: 
57:       @log = open_logfile log
58:       self.level = level
59:     end
silencer click to toggle source

Set to false to disable the silencer

    # File lib/active_support/buffered_logger.rb, line 26
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
79:     def add(severity, message = nil, progname = nil, &block)
80:       @log.add(severity, message, progname, &block)
81:     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
103:     def auto_flushing=(period)
104:     end
close() click to toggle source
     # File lib/active_support/buffered_logger.rb, line 116
116:     def close
117:       @log.close
118:     end
flush() click to toggle source
     # File lib/active_support/buffered_logger.rb, line 107
107:     def flush
108:     end
level() click to toggle source
    # File lib/active_support/buffered_logger.rb, line 71
71:     def level
72:       @log.level
73:     end
level=(l) click to toggle source
    # File lib/active_support/buffered_logger.rb, line 75
75:     def level=(l)
76:       @log.level = l
77:     end
open_log(log, mode) click to toggle source
    # File lib/active_support/buffered_logger.rb, line 63
63:     def open_log(log, mode)
64:       open(log, mode).tap do |open_log|
65:         open_log.set_encoding(Encoding::BINARY) if open_log.respond_to?(:set_encoding)
66:         open_log.sync = true
67:       end
68:     end
respond_to?(method, include_private = false) click to toggle source
     # File lib/active_support/buffered_logger.rb, line 111
111:     def respond_to?(method, include_private = false)
112:       return false if method.to_s == "flush"
113:       super
114:     end
silence(temporary_level = ERROR) click to toggle source

Silences the logger for the duration of the block.

    # File lib/active_support/buffered_logger.rb, line 30
30:     def silence(temporary_level = ERROR)
31:       if silencer
32:         begin
33:           logger = self.class.new @log_dest.dup, temporary_level
34:           yield logger
35:         ensure
36:           logger.close
37:         end
38:       else
39:         yield self
40:       end
41:     end

Private Instance Methods

open_logfile(log) click to toggle source
     # File lib/active_support/buffered_logger.rb, line 121
121:     def open_logfile(log)
122:       Logger.new log
123:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.