Please remove hard coded usage of the root logger from the logging module
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 38/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- observability-sre
Research direction
Start by inspecting the JABWrapper import path, including JABWrapper.jab_wrapper and JABWrapper.jab_types, and search the logging calls described in the issue. Check how importing the package affects the root logger and jab_wrapper.log, then verify that users can configure the JABWrapper logger without unwanted root handlers or formatters.
Written by the indexing model from the issue text.
Description
Hi there,
Just want to begin by saying I'm eternally grateful for the release of this module as a standalone package. This is a super clean general purpose implementation of JAB.
That being said, I'd really appreciate it if the calls to the root logger could be removed in a future release. At the moment I have to do something pretty hacky to stop the JABWrapper module from adding unwanted handlers and formatters to the root logger.
def monkey_patch_logging():
"""Initial Load of JABWrapper here to prevent it from using the root logger"""
class MetaReturnsCLS(type):
def __getattr__(cls, name):
return lambda *args, **kwargs: cls
class LoggingFacade(metaclass=MetaReturnsCLS):
jab_logger = logging.getLogger("JABWrapper")
debug = jab_logger.debug
info = jab_logger.info
DEBUG = logging.DEBUG
INFO = logging.INFO
sys.modules[logging.__name__] = LoggingFacade
import JABWrapper
from JABWrapper.jab_wrapper import JavaAccessBridgeWrapper
from JABWrapper.jab_types import JavaObject
sys.modules[logging.__name__] = logging
This is the only way I was able to both keep my logger hierarchy clean and prevent jab_wrapper.log files showing up in my project directory.
It'd be really simple to fix this issue, it'd only require that the method calls to the logging module itself be substituted with calls to a package local logger. Then, an importing user like myself could chose to enable/disable the logging therein.
import logging
# not this
logging.basicConfig(level=logging.DEBUG, handlers=[logging_file_handler, logging_stream_handler])
logging.debug("my debug message")
# do this
logger = logging.getLogger("JABWrapper")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging_file_handler)
logger.addHandler(logging_stream_handler)
logger.debug("my debug message")
Is this something you'd be willing accept pull requests on?
Thanks!
- Dominant language
- Python
- Stars
- 20
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from robocorp/java-access-bridge-wrapper
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
robocorp/java-access-bridge-wrapper#7 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
robocorp/java-access-bridge-wrapper#5 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
robocorp/java-access-bridge-wrapper#2 · 2 comments ·
All issues in robocorp/java-access-bridge-wrapper
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
raullenchai/Rapid-MLX#4042 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
LearningCircuit/local-deep-research#7067 ·
Maintainers usually reply within 1 day
-
#bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
apache/superset#44923 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
lawndoc/stack-back#123 ·