Skip to content

Commit

Permalink
Adapt logger to be reused in subscript_internal (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
berland authored Mar 25, 2021
1 parent 8bfc5bd commit 02c9b93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/subscript/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def getLogger(module_name="subscript"):
if not module_name:
return getLogger("subscript")

# This logger is also used by subscript-internal, but we
# don't want to expose that detail and repo difference in
# the log output:
module_name = module_name.replace("subscript_internal", "subscript")

compressed_name = []
for elem in module_name.split("."):
if len(compressed_name) == 0 or elem != compressed_name[-1]:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_subscriptlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ def test_subscriptlogger_name():
== "subscript.eclcompress.somesubmodule"
)

assert subscript.getLogger("subscript_internal").name == "subscript"
assert (
subscript.getLogger("subscript_internal.completor").name
== "subscript.completor"
)
assert (
subscript.getLogger("subscript_internal.completor.sub").name
== "subscript.completor.sub"
)


def test_default_logger_levels(capsys):
"""Verify that the intended usage of this logger have expected results"""
Expand Down

0 comments on commit 02c9b93

Please sign in to comment.