Class: Securial::Logger::Formatter::ColorfulFormatter
- Inherits:
-
Object
- Object
- Securial::Logger::Formatter::ColorfulFormatter
- Defined in:
- lib/securial/logger/formatter.rb
Overview
Formatter that adds color to log output for terminal display.
This formatter colorizes log messages based on their severity level, making them easier to distinguish in terminal output. It follows the standard Ruby Logger formatter interface.
Instance Method Summary collapse
-
#call(severity, timestamp, progname, msg) ⇒ String
Formats a log message with color based on severity.
Instance Method Details
#call(severity, timestamp, progname, msg) ⇒ String
Formats a log message with color based on severity.
71 72 73 74 75 76 77 |
# File 'lib/securial/logger/formatter.rb', line 71 def call(severity, , progname, msg) color = COLORS[severity] || CLEAR padded_severity = severity.ljust(SEVERITY_WIDTH) formatted = "[#{progname}][#{timestamp.strftime("%Y-%m-%d %H:%M:%S")}] #{padded_severity} -- #{msg}\n" "#{color}#{formatted}#{CLEAR}" end |