diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-04-19 00:28:08 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-04-19 00:28:08 +0000 |
commit | 0a2cb5093f7fbba370fd9b6caaf308139220b47b (patch) | |
tree | a84487a2a32f7fcba232035414392e0ef1226f15 /lib | |
parent | 8303d477a13a63e6b28666e04b0c62886feae48e (diff) | |
download | clogger-0a2cb5093f7fbba370fd9b6caaf308139220b47b.tar.gz |
This doesn't apply to people that use strftime()-formats, but that's a minority.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/clogger.rb | 4 | ||||
-rw-r--r-- | lib/clogger/pure.rb | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/clogger.rb b/lib/clogger.rb index e368115..be1bdce 100644 --- a/lib/clogger.rb +++ b/lib/clogger.rb @@ -19,8 +19,6 @@ class Clogger # support nginx variables that are less customizable than our own ALIASES = { '$request_time' => '$request_time{3}', - '$time_local' => '$time_local{%d/%b/%Y:%H:%M:%S %z}', - '$time_utc' => '$time_utc{%d/%b/%Y:%H:%M:%S %z}', '$msec' => '$time{3}', '$usec' => '$time{6}', '$http_content_length' => '$content_length', @@ -37,6 +35,8 @@ class Clogger :pid => 6, # getpid() :request_uri => 7, :time_iso8601 => 8, + :time_local => 9, + :time_utc => 10, } private diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb index a56b982..63907ae 100644 --- a/lib/clogger/pure.rb +++ b/lib/clogger/pure.rb @@ -137,6 +137,18 @@ private $$.to_s when :time_iso8601 Time.now.iso8601 + when :time_local + t = Time.now + off = t.utc_offset + sign = off < 0 ? '-' : '+' + sprintf("%02d/%s/%d:%02d:%02d:%02d #{sign}%02d%02d", + t.mday, Time::RFC2822_MONTH_NAME[t.mon - 1], + t.year, t.hour, t.min, t.sec, *(off.abs / 60).divmod(60)) + when :time_utc + t = Time.now.utc + sprintf("%02d/%s/%d:%02d:%02d:%02d +0000", + t.mday, Time::RFC2822_MONTH_NAME[t.mon - 1], + t.year, t.hour, t.min, t.sec) else raise "EDOOFUS #{special_nr}" end |