grammar Formatting rule format_string (token / literal)+ end rule literal . { def value(log_line, color) # context-independent... self.text_value end } end rule token remote_addr / remote_user / time_local / request / status / body_bytes_sent / upstream_response_time / request_time / http_referer / http_user_agent / proxy_addresses end rule remote_addr '%a' { def value(log_line, color) if color && Sickill::Rainbow.enabled # 24 = 15 + 9, the extra amount of bytes required for the ANSI escape codes... "%24s" % foreground(log_line.remote_address, color) else "%15s" % log_line.remote_address end end } end rule remote_user '%u' { def value(log_line, color) foreground(log_line.remote_user, color) end } end rule time_local '%t' { def value(log_line, color) foreground(log_line.to_date_s, color) end } end rule request '%r' { def value(log_line, color) foreground(log_line.to_request_s, color) end } end rule status '%s' { def value(log_line, color) foreground(log_line.status, color) end } end rule body_bytes_sent '%b' { def value(log_line, color) foreground(log_line.body_bytes_sent, color) end } end rule upstream_response_time '% { def value(log_line, color) foreground(log_line.upstream_response_time, color) end } end rule request_time '%T' { def value(log_line, color) foreground(log_line.request_time, color) end } end rule http_referer '%R' { def value(log_line, color) foreground(log_line.to_referer_s, color) end } end rule http_user_agent '%U' { def value(log_line, color) foreground(log_line.to_agent_s, color) end } end rule proxy_addresses '%p' { def value(log_line, color) (log_line.proxy_addresses || []).join(", ").foreground(color) end } end end # vim:syntax=ruby