clogger.git  about / heads / tags
configurable request logging for Rack
blob 9e4f59f645cad9172800ffc5c8616727c49295f8 831 bytes (raw)
$ git show v0.0.6:lib/clogger/format.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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

git clone https://yhbt.net/clogger.git