Class: Hanami::Logger::RackFormatter Private
- Inherits:
-
Dry::Logger::Formatters::String
- Object
- Dry::Logger::Formatters::String
- Hanami::Logger::RackFormatter
- Defined in:
- lib/hanami/logger/rack_formatter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Rack request log formatter for Dry Logger.
Formats rack request log entries with colorized output for HTTP verbs, status codes, and request paths, making it easier to visually scan logs in development.
HTTP verbs each have a distinct color. Status codes follow traffic-light coloring (2xx green, 3xx cyan, 4xx yellow, 5xx red), and the request path echoes the status color so both signals reinforce each other at a glance.
Colorization is only active when ‘colorize: true` is set in the logger options (the default in development).
Constant Summary collapse
- RACK_TEMPLATE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
<<~TEXT [%<progname>s] [%<severity>s] [%<time>s] \ %<verb>s %<status>s %<elapsed>s %<ip>s %<path>s %<length>s %<payload>s %<params>s TEXT
- VERB_COLORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ "GET" => :green, "POST" => :yellow, "PUT" => :blue, "PATCH" => :blue, "DELETE" => :red, "HEAD" => :cyan }.freeze
Instance Method Summary collapse
-
#initialize(**options) ⇒ RackFormatter
constructor
private
A new instance of RackFormatter.
Constructor Details
#initialize(**options) ⇒ RackFormatter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RackFormatter.
39 40 41 42 |
# File 'lib/hanami/logger/rack_formatter.rb', line 39 def initialize(**) super @template = Dry::Logger::Formatters::Template[RACK_TEMPLATE] end |