Merb::Logger = Extlib::Logger
Ruby (standard) logger levels:
:fatal |
An unhandleable error that results in a program crash |
:error |
A handleable error condition |
:warn |
A warning |
:info |
generic (useful) information about system operation |
:debug |
low-level information for developers |
Appends a message to the log. The methods yield to an optional block and the output of this block will be appended to the message.
string<String> |
The message to be logged. Defaults to nil. |
The resulting message added to the log file. |
# File lib/merb-core/logger.rb, line 143 def <<(string = nil) message = "" message << delimiter message << string if string message << "\n" unless message[-1] == \n\ @buffer << message flush if @auto_flush message end
Close and remove the current log object.
# File lib/merb-core/logger.rb, line 129 def close flush @log.close if @log.respond_to?(:close) && !@log.tty? @log = nil end
Flush the entire buffer to the log object.
# File lib/merb-core/logger.rb, line 121 def flush return unless @buffer.size > 0 @mutex.synchronize do @log.write(@buffer.slice!(0..-1).join('')) end end
Replaces an existing logger with a new one.
stream<IO, String> |
Either an IO object or a name of a logfile. |
log_level<~to_sym> |
The log level from, e.g. :fatal or :info. Defaults to :error in the production environment and :debug otherwise. |
delimiter<String> |
Delimiter to use between message sections. Defaults to “ ~ ”. |
auto_flush<Boolean> |
Whether the log should automatically flush after new messages are added. Defaults to false. |
# File lib/merb-core/logger.rb, line 100 def set_log(stream = Merb::Config[:log_stream], log_level = Merb::Config[:log_level], delimiter = Merb::Config[:log_delimiter], auto_flush = Merb::Config[:log_auto_flush]) @buffer = [] @delimiter = delimiter @auto_flush = auto_flush if Levels[log_level] @level = Levels[log_level] else @level = log_level end @log = stream @log.sync = true @mutex = (@@mutex[@log] ||= Mutex.new) end
Generated with the Darkfish Rdoc Generator 2.