Class: Securial::Logger::Formatter::PlainFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/securial/logger/formatter.rb

Overview

Formatter that produces plain text log output without colors.

This formatter is suitable for file logging or environments where terminal colors are not supported. It follows the standard Ruby Logger formatter interface.

Examples:

logger = Logger.new('application.log')
logger.formatter = Securial::Logger::Formatter::PlainFormatter.new

Instance Method Summary collapse

Instance Method Details

#call(severity, timestamp, progname, msg) ⇒ String

Formats a log message in plain text without color codes.

Parameters:

  • severity (String)

    Log severity level (DEBUG, INFO, etc.)

  • timestamp (Time)

    Time when the log event occurred

  • progname (String)

    Program name or context for the log message

  • msg (String)

    The log message itself

Returns:

  • (String)

    Formatted log message as plain text



99
100
101
102
103
104
# File 'lib/securial/logger/formatter.rb', line 99

def call(severity, timestamp, progname, msg)
  padded_severity = severity.ljust(SEVERITY_WIDTH)
  formatted = "[#{timestamp.strftime("%Y-%m-%d %H:%M:%S")}] #{padded_severity} -- #{msg}\n"

  formatted
end