Class: Console::JavaUtilLogger::ColorConsoleHandler
- Inherits:
-
ConsoleHandler
- Object
- ConsoleHandler
- Console::JavaUtilLogger::ColorConsoleHandler
- Defined in:
- lib/color_console/java_util_logger.rb
Overview
Extends the java.util.ConsoleHandler, adding colorised logging output to the console.
Instance Method Summary collapse
-
#initialize(format = RubyFormatter::DEFAULT_FORMAT) ⇒ ColorConsoleHandler
constructor
A new instance of ColorConsoleHandler.
-
#publish(log_record) ⇒ Object
Publishes a log record by outputting it to the console, using an appropriate color for the severity of the log message.
Constructor Details
#initialize(format = RubyFormatter::DEFAULT_FORMAT) ⇒ ColorConsoleHandler
Returns a new instance of ColorConsoleHandler.
18 19 20 21 |
# File 'lib/color_console/java_util_logger.rb', line 18 def initialize(format = RubyFormatter::DEFAULT_FORMAT) super() self.formatter = RubyFormatter.new(format) end |
Instance Method Details
#publish(log_record) ⇒ Object
Publishes a log record by outputting it to the console, using an appropriate color for the severity of the log message.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/color_console/java_util_logger.rb', line 26 def publish(log_record) msg = formatter.format(log_record) case log_record.level when JavaUtilLogger::Level::INFO Console.write msg, :white when JavaUtilLogger::Level::CONFIG Console.write msg, :cyan when JavaUtilLogger::Level::FINE Console.write msg, :light_gray when JavaUtilLogger::Level::SEVERE Console.write msg, :red when JavaUtilLogger::Level::WARNING Console.write msg, :yellow else Console.write msg, :dark_gray end end |