lumber 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/VERSION +1 -1
- data/lib/lumber/lumber.rb +1 -1
- data/test/lumber_test.rb +24 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.2
|
data/lib/lumber/lumber.rb
CHANGED
@@ -139,7 +139,7 @@ module Lumber
|
|
139
139
|
# logger of the new class
|
140
140
|
parent = clazz.superclass
|
141
141
|
while ! parent.nil?
|
142
|
-
if
|
142
|
+
if parent.method_defined?(:logger) && parent.method_defined?(:logger=) && parent.logger
|
143
143
|
parent_is_registered = @@registered_loggers.values.find {|v| parent.logger.fullname.index(v) == 0}
|
144
144
|
if parent_is_registered
|
145
145
|
clazz.logger = Log4r::Logger.new("#{parent.logger.fullname}::#{clazz.name}")
|
data/test/lumber_test.rb
CHANGED
@@ -48,6 +48,30 @@ class LumberTest < Test::Unit::TestCase
|
|
48
48
|
assert_valid_logger('Foo1', "root::foo1")
|
49
49
|
end
|
50
50
|
|
51
|
+
should "not register new logger for subclasses of classes that delegate logger" do
|
52
|
+
assert !defined?(Foo1) # ActionController::Base
|
53
|
+
assert !defined?(Foo2) # ActionView::Base
|
54
|
+
assert !defined?(Foo3) # Subclass of ActionView::Base
|
55
|
+
Lumber.setup_logger_hierarchy("Foo1", "root::foo1")
|
56
|
+
eval "class ::Foo1; end"
|
57
|
+
eval "class ::Foo2; delegate :logger, :to => Foo1; end"
|
58
|
+
eval "class ::Foo3 < Foo2; end"
|
59
|
+
assert_valid_logger('Foo1', "root::foo1")
|
60
|
+
assert Foo2.new.logger == Foo1.logger
|
61
|
+
assert Foo3.new.logger == Foo1.logger
|
62
|
+
end
|
63
|
+
|
64
|
+
should "allow registering independent loggers for classes in a hierarchy" do
|
65
|
+
assert !defined?(Foo1)
|
66
|
+
assert !defined?(Foo2)
|
67
|
+
Lumber.setup_logger_hierarchy("Foo1", "root::foo1")
|
68
|
+
Lumber.setup_logger_hierarchy("Foo2", "root::foo2")
|
69
|
+
new_class('Foo1')
|
70
|
+
new_class('Foo2', 'Foo1')
|
71
|
+
assert_valid_logger('Foo1', "root::foo1")
|
72
|
+
assert_valid_logger('Foo2', "root::foo2")
|
73
|
+
end
|
74
|
+
|
51
75
|
should "prevent cattr_accessor for a class registered before the class is defined" do
|
52
76
|
assert !defined?(Foo1)
|
53
77
|
Lumber.setup_logger_hierarchy("Foo1", "root::foo1")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Conway
|
@@ -13,7 +13,7 @@ date: 2009-10-16 00:00:00 -04:00
|
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: shoulda
|
17
17
|
type: :development
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|