Module: DevSuite::Utils::Logger::Formatter

Defined in:
lib/dev_suite/utils/logger/formatter.rb

Constant Summary collapse

LOG_DETAILS =
{
  none: { prefix: "", color: :white },
  info: { prefix: "[INFO]", color: :green },
  warn: { prefix: "[WARNING]", color: :yellow },
  error: { prefix: "[ERROR]", color: :red },
  debug: { prefix: "[DEBUG]", color: :blue },
}.freeze

Class Method Summary collapse

Class Method Details

.format(message, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dev_suite/utils/logger/formatter.rb', line 16

def format(message, options = {})
  return "" if message.nil? || message.strip.empty?

  details = fetch_log_details(options[:level])
  prefix = options[:prefix] || details[:prefix]
  color = options[:color] || details[:color]
  emoji_icon = Emoji.resolve(options[:emoji])

  formatted_message = build_message(prefix, emoji_icon, message)
  Utils::Color.colorize(formatted_message, color: color)
end