Skip to content

Instantly share code, notes, and snippets.

@Ryaang
Last active December 27, 2023 02:35
Show Gist options
  • Select an option

  • Save Ryaang/d10c9e4a5b46f6989f696758ff2f039b to your computer and use it in GitHub Desktop.

Select an option

Save Ryaang/d10c9e4a5b46f6989f696758ff2f039b to your computer and use it in GitHub Desktop.
My log template for python using colorlog
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