Class: Makit::Logging::PlainFormatter 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::FileSink instead.

Plain text log formatter that strips ANSI color codes

This formatter removes color codes from log messages and provides clean, plain text output suitable for file logging or systems that don’t support color output.

Instance Method Summary collapse

Instance Method Details

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

Format a log message as plain text

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 plain text log entry



129
130
131
132
133
134
# File 'lib/makit/logging.rb', line 129

def call(severity, time, _progname, msg)
  warn "Makit::Logging::PlainFormatter is deprecated and will be removed in version 0.2.0. Use Makit::Logging::Logger with Makit::Logging::Sinks::FileSink instead."
  stripped_msg = msg.gsub(ANSI_COLOR_REGEX, "") # Remove ANSI color codes
  timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
  "[#{timestamp}] #{severity}: #{stripped_msg}\n"
end