about summary refs log tree commit homepage
path: root/lib/clogger/format.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-08-28 20:47:43 -0700
committerEric Wong <normalperson@yhbt.net>2009-08-28 20:48:10 -0700
commita70468036d9b780bc7ec921f7feb6e1275778169 (patch)
tree302c8b4f4a30203c9549dbd7579006a729c1830f /lib/clogger/format.rb
downloadclogger-a70468036d9b780bc7ec921f7feb6e1275778169.tar.gz
Diffstat (limited to 'lib/clogger/format.rb')
-rw-r--r--lib/clogger/format.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/clogger/format.rb b/lib/clogger/format.rb
new file mode 100644
index 0000000..9e4f59f
--- /dev/null
+++ b/lib/clogger/format.rb
@@ -0,0 +1,25 @@
+# -*- encoding: binary -*-
+
+class Clogger
+
+  # predefined log formats in wide use
+  module Format
+    # common log format used by Apache:
+    # http://httpd.apache.org/docs/2.2/logs.html
+    Common = "$remote_addr - $remote_user [$time_local] " \
+             '"$request" $status $response_length'.freeze
+
+    # combined log format used by Apache:
+    # http://httpd.apache.org/docs/2.2/logs.html
+    Combined = %Q|#{Common} "$http_referer" "$http_user_agent"|.freeze
+
+    # combined log format used by nginx:
+    # http://wiki.nginx.org/NginxHttpLogModule
+    NginxCombined = Combined.gsub(/response_length/, 'body_bytes_sent').freeze
+
+    # log format used by Rack 1.0
+    Rack_1_0 = "$ip - $remote_user [$time_local{%d/%b/%Y %H:%M:%S}] " \
+               '"$request" $status $response_length $request_time{4}'.freeze
+  end
+
+end