ABOUT
The 'buffered_logger' gem is an extension to ActiveSupport::BufferedLogger which
gives the the little logger some much needed formatting support. The actual
logging work is still delegated to to active_support/buffered_logger.
FEATURES
- per thread indentation
- per thread auto flush setting
- temporary indentation blocks
- per severity formatting
- ansi color output formats
USAGE
default initialization
l = BufferedLogger.new(STDOUT)
changing the severity level
l.level = :warn
l.level = 1
formatter constructor (initializes the master thread's formatters)
l = BufferedLogger.new(STDOUT, :debug,
{ :info => "$green INFO: $white %s",
:warn => "$yellow WARNING: $white %s",
:error => "$red ERROR: $white %s" } )
setting formatting after initialization
l.info_formatter = "$green INFO: $white %s",
l.warn_formatter = "$yellow WARNING: $white %s"
l.error_formatter = "$red ERROR: $white %s"
checking the current thread's formatting
l.info_formatter.to_s
l.warn_formatter.to_s
...
checking the current thread's indentation
l.padding.to_s
setting the current thread's indentation
l.indent(4) # move cursor right 4 spaces
l.indent(-2) # move cursor left 2 spaces
l.indent(:reset) # reset indentation
temporarily indenting using an indent block
l.indent do
l.info 'some info'
...
l.info 'some more info'
end
setting auto_flushing
l.auto_flushing = 2
USAGE DETAILS