Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Please remove hard coded usage of the root logger from the logging module

Ouverte
#17 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
38/100
Type d'issue
Refactorisation
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
python

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

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!

Langage dominant
Python
Étoiles
20
Forks
8
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de robocorp/java-access-bridge-wrapper

Toutes les issues de robocorp/java-access-bridge-wrapper

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.