Skip to content

Commit

Permalink
Width formatting for %T and %<T
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdb committed Jan 6, 2014
1 parent 6fa7969 commit 851daf5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions lib/ntail/formatting.rb
Expand Up @@ -352,7 +352,12 @@ def _nt_body_bytes_sent

module UpstreamResponseTime0
def value(log_line, color)
foreground(log_line.upstream_response_time, color)
if color && Sickill::Rainbow.enabled
# 15 = 6 + 9, the extra amount of bytes required for the ANSI escape codes...
"%15s" % foreground(log_line.upstream_response_time, color)
else
"%6s" % log_line.upstream_response_time
end
end
end

Expand Down Expand Up @@ -383,7 +388,12 @@ def _nt_upstream_response_time

module RequestTime0
def value(log_line, color)
foreground(log_line.request_time, color)
if color && Sickill::Rainbow.enabled
# 15 = 6 + 9, the extra amount of bytes required for the ANSI escape codes...
"%15s" % foreground(log_line.request_time, color)
else
"%6s" % log_line.request_time
end
end
end

Expand Down
14 changes: 12 additions & 2 deletions lib/ntail/formatting.treetop
Expand Up @@ -73,15 +73,25 @@ grammar Formatting
rule upstream_response_time
'%<T' <Node> {
def value(log_line, color)
foreground(log_line.upstream_response_time, color)
if color && Sickill::Rainbow.enabled
# 15 = 6 + 9, the extra amount of bytes required for the ANSI escape codes...
"%15s" % foreground(log_line.upstream_response_time, color)
else
"%6s" % log_line.upstream_response_time
end
end
}
end

rule request_time
'%T' <Node> {
def value(log_line, color)
foreground(log_line.request_time, color)
if color && Sickill::Rainbow.enabled
# 15 = 6 + 9, the extra amount of bytes required for the ANSI escape codes...
"%15s" % foreground(log_line.request_time, color)
else
"%6s" % log_line.request_time
end
end
}
end
Expand Down

0 comments on commit 851daf5

Please sign in to comment.