PYTHON:如何避免包覆盖我的日志记录

时间:2021-05-17 22:36:22

标签: python python-3.x logging package i2c

我的 python 日志有问题。 我已经配置了这样的日志轮换:

# log config
logname = "logs.log"
logFile = "{}/logs/{}".format(workdir, logname)
# handler
handler = TimedRotatingFileHandler(filename=logFile, when="midnight", interval=1, )
handler.suffix = "%Y-%m-%d"
logging.basicConfig(format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
                    datefmt='%Y-%m-%d:%H:%M:%S',
                    level=logging.DEBUG,
                    handlers=[handler]
                    )
logger = logging.getLogger('MyLogger')

但是我从其他包(SSD1306 和 I2C)中写回了这样的:

2021-05-18:00:23:19,491 DEBUG    [SSD1306.py:104] Using hardware I2C with platform I2C provider.
2021-05-18:00:23:19,542 DEBUG    [I2C.py:118] Wrote 0xAE to register 0x00
2021-05-18:00:23:19,543 DEBUG    [I2C.py:118] Wrote 0xD5 to register 0x00

我怎样才能避免这种情况发生,而且日志只涉及我写的脚本

谢谢

0 个答案:

没有答案