Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在终端打印重复日志的问题 #268

Open
kushidou opened this issue Mar 9, 2023 · 4 comments
Open

在终端打印重复日志的问题 #268

kushidou opened this issue Mar 9, 2023 · 4 comments

Comments

@kushidou
Copy link

kushidou commented Mar 9, 2023

月初换了台VPS,就重新安装了一次Hoshino,python版本从原来的3.8更改到了3.9,现在发现Hoshino正常运行之后,打印日志都会打印两遍。
本来以为是自己插件使用了loguru引起的,现在已经把自己的插件完整移除了,还是有这个问题。(图片最后两行)
image

@Ice9Coffee
Copy link
Owner

#249 应该是同样的问题。可能是某些插件重复定义了logger?
之前我也遇到过,似乎是触发某个功能后就开始风怒日志(日志的格式并不一样),但后来自己消失了,现在复现不出来。
目前我这边部署的Hoshino并没有出现这个问题,期待有闲人定位一下bug(毕竟不影响使用)

@clacknya
Copy link

看看 logging.Logger.manager.loggerDict.items() 是不是多定义了 Handler

参考

import logging

def listloggers():
    rootlogger = logging.getLogger()
    print(rootlogger)
    for h in rootlogger.handlers:
        print('     %s' % h)

    for nm, lgr in logging.Logger.manager.loggerDict.items():
        print('+ [%-20s] %s ' % (nm, lgr))
        if not isinstance(lgr, logging.PlaceHolder):
            for h in lgr.handlers:
                print('     %s' % h)

@clacknya
Copy link

试试把 nonebot 自己定义的 handlerremove 掉。

https://github.com/nonebot/nonebot/blob/e66b24fa865f0e2a20caf0a53a1639b914d6b0f3/nonebot/log.py#L19-L22

logger.removeHandler(default_handler)

@SlightDust
Copy link

SlightDust commented Apr 15, 2024

今天为了更autopcr,更了一下这几个模块,然后就开始一条日志打两遍了
quart~=0.19.1
Jinja2~=3.1.3
markupsafe~=2.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants