lumber 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/VERSION +1 -1
- data/lib/lumber/lumber.rb +5 -6
- data/test/lumber_test.rb +13 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.3
|
data/lib/lumber/lumber.rb
CHANGED
@@ -139,12 +139,11 @@ module Lumber
|
|
139
139
|
# logger of the new class
|
140
140
|
parent = clazz.superclass
|
141
141
|
while ! parent.nil?
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
142
|
+
parent_logger_name = parent.logger.fullname rescue ''
|
143
|
+
parent_is_registered = @@registered_loggers.values.find {|v| parent_logger_name.index(v) == 0}
|
144
|
+
if parent_is_registered && parent.method_defined?(:logger=)
|
145
|
+
clazz.logger = Log4r::Logger.new("#{parent_logger_name}::#{clazz.name}")
|
146
|
+
break
|
148
147
|
end
|
149
148
|
parent = parent.superclass
|
150
149
|
end
|
data/test/lumber_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
|
2
|
+
require 'delegate'
|
3
3
|
|
4
4
|
def new_class(class_name, super_class=nil, super_module=nil)
|
5
5
|
s = "class #{class_name}"
|
@@ -61,6 +61,18 @@ class LumberTest < Test::Unit::TestCase
|
|
61
61
|
assert Foo3.new.logger == Foo1.logger
|
62
62
|
end
|
63
63
|
|
64
|
+
should "no logger when parent is via delegate class" do
|
65
|
+
assert !defined?(Foo1)
|
66
|
+
assert !defined?(Foo2)
|
67
|
+
assert !defined?(Foo3)
|
68
|
+
Lumber.setup_logger_hierarchy("Foo1", "root::foo1")
|
69
|
+
eval "class ::Foo1; end"
|
70
|
+
eval "class ::Foo2 < DelegateClass(Foo1); end"
|
71
|
+
eval "class ::Foo3 < Foo2; end"
|
72
|
+
assert_valid_logger('Foo1', "root::foo1")
|
73
|
+
assert ! defined?(Foo3.logger)
|
74
|
+
end
|
75
|
+
|
64
76
|
should "allow registering independent loggers for classes in a hierarchy" do
|
65
77
|
assert !defined?(Foo1)
|
66
78
|
assert !defined?(Foo2)
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Conway
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-20 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|