plotly / plotly/plotly.py

Log messages appearing twice with Python Logging after pio.renderers.default = "notebook"

未关闭
#5,247 5 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P2
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

After importing plotly.io and setting the pio.renderers.default = "notebook" in my Python code, All Log messages appearing twice with Python Logging

python version: 3.9.12
plotly version: 6.1.2

import logging

# create logger
logger = logging.getLogger('simple_example')
logger.setLevel(logging.DEBUG)

# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

# create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# add formatter to ch
ch.setFormatter(formatter)

# add ch to logger
logger.addHandler(ch)

## print some message
logger.info("hello test")    #### till this point all looks good

## now import plotly
import plotly.io as pio
pio.renderers.default = "notebook"

## use the logger again , now the same logger.info printing the log message twice
logger.info("hello test after import")

Image

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先运行 issue 中的 Python logging 示例,尤其要检查 import plotly.io 以及将 pio.renderers.default 设置为 "notebook" 的部分。跟踪 renderer 的设置过程和 logging handler,以确定为什么第二次调用 logger.info 会被输出两次;完成的标准是:选择 notebook renderer 后,消息只出现一次,并且该行为有回归测试覆盖。

由索引模型根据 Issue 内容生成。

评估

技术栈
jupyter-notebook, plotly, python
领域
observability
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。