Class: Makit::Logging::ColorFormatter Deprecated

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/makit/logging.rb

Overview

Deprecated.

This class is deprecated and will be removed in version 0.2.0. Use Makit::Logging::Logger with Makit::Logging::Sinks::Console instead.

Colored log formatter for terminal output

This formatter adds appropriate colors to different log levels to improve readability in terminal environments. Colors are: DEBUG (light blue), INFO (green), WARN (yellow), ERROR (red), FATAL (bold red)

Instance Method Summary collapse

Instance Method Details

#call(severity, time, _progname, msg) ⇒ String

Format a log message with colors

Parameters:

  • severity (String)

    log level (DEBUG, INFO, WARN, ERROR, FATAL)

  • time (Time)

    timestamp of the log message

  • _progname (String)

    program name (unused)

  • msg (String)

    the log message content

Returns:

  • (String)

    formatted colored log entry



153
154
155
156
157
158
# File 'lib/makit/logging.rb', line 153

def call(severity, time, _progname, msg)
  warn "Makit::Logging::ColorFormatter is deprecated and will be removed in version 0.2.0. Use Makit::Logging::Logger with Makit::Logging::Sinks::Console instead."
  timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
  colored_severity = colorize_severity(severity)
  "[#{timestamp}] #{colored_severity}: #{msg}\n"
end