Last active
December 27, 2023 02:35
-
-
Save Ryaang/d10c9e4a5b46f6989f696758ff2f039b to your computer and use it in GitHub Desktop.
My log template for python using colorlog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import colorlog | |
| fmt = "{asctime} {log_color}{levelname} {name}: {message}" | |
| colorlog.basicConfig(style="{", format=fmt, stream=None) | |
| # logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s",stream=None) | |
| log = logging.getLogger(name="test") | |
| # 放到main使用 | |
| log.setLevel(logging.DEBUG) | |
| log.info("hello") | |
| # logging配置详解: https://zhuanlan.zhihu.com/p/166671955 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment