| 123456789101112131415161718192021 |
- # vs_log_macros.py
- import logging
- import os
- # 配置日志
- # 默认INFO级别,格式包含线程名
- logging.basicConfig(level=os.environ.get("VSC_LOG_LEVEL", "INFO").upper(),
- format='[%(levelname)s] [%(threadName)s] %(message)s')
- # 定义快捷日志函数,模仿C++的宏
- def VSC_INFO(tag, message, *args):
- logging.info(f"[{tag}] {message}", *args)
- def VSC_DEBUG(tag, message, *args):
- logging.debug(f"[{tag}] {message}", *args)
- def VSC_WARN(tag, message, *args):
- logging.warning(f"[{tag}] {message}", *args)
- def VSC_ERROR(tag, message, *args):
- logging.error(f"[{tag}] {message}", *args)
|