lib/semantic_logger/logger.rb in semantic_logger-4.0.0 vs lib/semantic_logger/logger.rb in semantic_logger-4.1.0

- old
+ new

@@ -11,11 +11,11 @@ # logger = SemanticLogger::Logger.new(self) # OR # logger = SemanticLogger::Logger.new('MyClass') # # Parameters: - # application + # klass # A class, module or a string with the application/class name # to be used in the logger # # level # The initial log level to start with for this logger instance @@ -24,49 +24,39 @@ # filter [Regexp|Proc] # RegExp: Only include log messages where the class name matches the supplied # regular expression. All other messages will be ignored # Proc: Only include log messages where the supplied Proc returns true # The Proc must return true or false - def initialize(klass, level=nil, filter=nil) - super + def initialize(klass, level = nil, filter = nil) + super(klass, level, filter) end - # Returns [Integer] the number of log entries that have not been written - # to the appenders - # - # When this number grows it is because the logging appender thread is not - # able to write to the appenders fast enough. Either reduce the amount of - # logging, increase the log level, reduce the number of appenders, or - # look into speeding up the appenders themselves + # Place log request on the queue for the Appender thread to write to each + # appender in the order that they were registered + def log(log, message = nil, progname = nil, &block) + # Compatibility with ::Logger + return add(log, message, progname, &block) unless log.is_a?(SemanticLogger::Log) + Processor << log + end + + # DEPRECATED def self.queue_size Processor.queue_size end - # Flush all queued log entries disk, database, etc. - # All queued log messages are written and then each appender is flushed in turn + # DEPRECATED def self.flush - Processor.submit_request(:flush) + Processor.flush end - # Close all appenders and flush any outstanding messages + # DEPRECATED def self.close - Processor.submit_request(:close) + Processor.close end - # Allow the internal logger to be overridden from its default of STDERR - # Can be replaced with another Ruby logger or Rails logger, but never to - # SemanticLogger::Logger itself since it is for reporting problems - # while trying to log to the various appenders + # DEPRECATED def self.logger=(logger) Processor.logger = logger - end - - # Place log request on the queue for the Appender thread to write to each - # appender in the order that they were registered - def log(log, message = nil, progname = nil, &block) - # Compatibility with ::Logger - return add(log, message, progname, &block) unless log.is_a?(SemanticLogger::Log) - Processor << log end end end