本文整理匯總了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