about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-03-16 16:35:40 -0700
committerEric Wong <normalperson@yhbt.net>2011-03-16 16:35:40 -0700
commitb086541910c5797732886c7f0d276871f2775d08 (patch)
tree0234a9189753f0b8d3cf13695fa351e11e27acc3
parent9102cb13084980f1899b488627b354fc16bc38eb (diff)
This allows using:

  use Clogger, :format => :Rack_1_0

Instead of:

  use Clogger, :format => Clogger::Format::Rack_1_0
-rw-r--r--lib/clogger.rb1
-rw-r--r--test/test_clogger.rb5
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/clogger.rb b/lib/clogger.rb
index cead30b..8058390 100644
--- a/lib/clogger.rb
+++ b/lib/clogger.rb
@@ -55,6 +55,7 @@ private
                         \w*))?([^$]*)/x
 
   def compile_format(str, opt = {})
+    str = Clogger::Format.const_get(str) if Symbol === str
     longest_day = Time.at(26265600) # "Saturday, November 01, 1970 00:00:00"
     rv = []
     opt ||= {}
diff --git a/test/test_clogger.rb b/test/test_clogger.rb
index 425a4e1..06942c4 100644
--- a/test/test_clogger.rb
+++ b/test/test_clogger.rb
@@ -37,6 +37,11 @@ class TestClogger < Test::Unit::TestCase
     assert_raise(ArgumentError) { Clogger.new }
   end
 
+  def test_clogger_sym_format
+    app = lambda { |env| [ 0, {}, [] ] }
+    tmp = Clogger.new app, :format => :Rack_1_0, :logger => $stderr
+  end
+
   def test_init_stderr
     cl = Clogger.new(lambda { |env| [ 0, {}, [] ] }, :logger => $stderr)
     assert_kind_of(Integer, cl.fileno)