Skip to content

Commit

Permalink
Merge pull request orocos-toolchain#34 from orocos-toolchain/fix_logg…
Browse files Browse the repository at this point in the history
…er_hierarchy_corner_case

logger: include the superclass when resolving the default logger
  • Loading branch information
doudou authored Dec 23, 2016
2 parents 890bf09 + df14da4 commit f4c6e8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/utilrb/logger/hierarchy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ def logger
break
end
end

if m.respond_to?(:superclass)
m = m.superclass
if m.respond_to?(:logger)
parent_module = m
break
end
else
m = nil; break
end
Expand Down
4 changes: 4 additions & 0 deletions test/test_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def test_hierarchy_can_resolve_parent_logger_with_identical_name
def test_hierarchy_can_resolve_parent_logger_in_subclasses_where_the_subclass_parent_module_is_not_providing_a_logger
assert_equal "root_logger", NotALoggingModule::HierarchyTest.logger
end
def test_hierarchy_resolution_starts_at_superclass_if_enclosing_module_does_not_provide_a_logger
flexmock(HierarchyTest::HierarchyTest).should_receive(logger: "specific_class_logger")
assert_equal "specific_class_logger", NotALoggingModule::HierarchyTest.logger
end
def test_hierarchy_resolves_the_parent_module_first_even_in_subclasses
assert_equal "other_logger", HierarchyTestForSubclass::HierarchyTest.logger
end
Expand Down

0 comments on commit f4c6e8e

Please sign in to comment.