Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#17 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
38/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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!

主要言語
Python
スター
20
フォーク
8
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

robocorp/java-access-bridge-wrapper のほかの issue

robocorp/java-access-bridge-wrapper の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。