lib/clogger/pure.rb in clogger-0.5.0 vs lib/clogger/pure.rb in clogger-0.6.0

- old
+ new

@@ -12,11 +12,16 @@ # trigger autoload to avoid thread-safety issues later on Rack::Utils::HeaderHash.new({}) @app = app @logger = opts[:logger] - (@logger.sync = true) rescue nil + path = opts[:path] + path && @logger and + raise ArgumentError, ":logger and :path are independent" + path and @logger = File.open(path, "ab") + + @logger.sync = true if @logger.respond_to?(:sync=) @fmt_ops = compile_format(opts[:format] || Format::Common, opts) @wrap_body = need_wrap_body?(@fmt_ops) @reentrant = opts[:reentrant] @need_resp = need_response_headers?(@fmt_ops) @body_bytes_sent = 0 @@ -67,11 +72,11 @@ def wrap_body? @wrap_body end def fileno - @logger.fileno rescue nil + @logger.respond_to?(:fileno) ? @logger.fileno : nil end private def byte_xs(s) @@ -136,10 +141,10 @@ when OP_REQUEST_TIME t = Time.now - @start time_format(t.to_i, (t - t.to_i) * 1000000, op[1], op[2]) when OP_TIME t = Time.now - time_format(t.sec, t.usec, op[1], op[2]) + time_format(t.to_i, t.usec, op[1], op[2]) when OP_COOKIE (env['rack.request.cookie_hash'][op[1]] rescue "-") || "-" else raise "EDOOFUS #{op.inspect}" end