From 9b46379f75f384c86e42046ab03ce55231197c92 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 24 Dec 2010 13:23:32 -0800 Subject: accept a new :path argument in initialize This lessens confusion for people configuring Clogger in config.ru, since "File" could be mistaken for Rack::File and "::File" needs to be specified. --- lib/clogger/pure.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/clogger/pure.rb') diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb index 0dd5021..452e232 100644 --- a/lib/clogger/pure.rb +++ b/lib/clogger/pure.rb @@ -14,7 +14,12 @@ class Clogger @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] @@ -69,7 +74,7 @@ class Clogger end def fileno - @logger.fileno rescue nil + @logger.respond_to?(:fileno) ? @logger.fileno : nil end private -- cgit v1.2.3-24-ge0c7