本文整理汇总了Python中coloredlogs.DEFAULT_LOG_FORMAT属性的典型用法代码示例。如果您正苦于以下问题:Python coloredlogs.DEFAULT_LOG_FORMAT属性的具体用法?Python coloredlogs.DEFAULT_LOG_FORMAT怎么用?Python coloredlogs.DEFAULT_LOG_FORMAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类coloredlogs
的用法示例。
在下文中一共展示了coloredlogs.DEFAULT_LOG_FORMAT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_logger
# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import DEFAULT_LOG_FORMAT [as 别名]
def get_logger(name='', debug=None, format=None):
import coloredlogs
# logging.basicConfig() # this will make paramiko log a lot of stuff
logger = logging.getLogger(name if name else 'aetros')
level = 'INFO'
fmt = '%(message)s' if format is None else format
if debug is None:
debug = is_debug()
if debug:
level = 'DEBUG'
if format is None:
fmt = coloredlogs.DEFAULT_LOG_FORMAT
atty = None
if '1' == os.getenv('AETROS_ATTY'):
atty = True
coloredlogs.install(fmt=fmt, level=level, logger=logger, isatty=atty)
return logger
示例2: set_log_format
# 需要导入模块: import coloredlogs [as 别名]
# 或者: from coloredlogs import DEFAULT_LOG_FORMAT [as 别名]
def set_log_format():
if core_args.level < 20:
log_format = "%(asctime)s [%(levelname)s] %(message)s"
coloredlogs.DEFAULT_LOG_FORMAT = log_format
coloredlogs.DEFAULT_FIELD_STYLES = {
"levelname": {"color": "cyan", "bold": True}
}
coloredlogs.DEFAULT_LEVEL_STYLES = {
"warning": {"color": "yellow", "bold": True},
"success": {"color": "green", "bold": True},
"error": {"color": "red", "bold": True},
}
else:
log_format = "%(message)s"
coloredlogs.DEFAULT_LOG_FORMAT = log_format
coloredlogs.DEFAULT_LEVEL_STYLES = {
"warning": {"color": "yellow", "bold": True},
"success": {"color": "green", "bold": True},
"error": {"color": "red", "bold": True},
}
return log_format