當前位置: 首頁>>代碼示例>>Python>>正文


Python coloredlogs.DEFAULT_LEVEL_STYLES屬性代碼示例

本文整理匯總了Python中coloredlogs.DEFAULT_LEVEL_STYLES屬性的典型用法代碼示例。如果您正苦於以下問題:Python coloredlogs.DEFAULT_LEVEL_STYLES屬性的具體用法?Python coloredlogs.DEFAULT_LEVEL_STYLES怎麽用?Python coloredlogs.DEFAULT_LEVEL_STYLES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在coloredlogs的用法示例。


在下文中一共展示了coloredlogs.DEFAULT_LEVEL_STYLES屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: set_log_format

# 需要導入模塊: import coloredlogs [as 別名]
# 或者: from coloredlogs import DEFAULT_LEVEL_STYLES [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 
開發者ID:mozilla,項目名稱:iris,代碼行數:24,代碼來源:logger_manager.py

示例2: _update_log_color_set

# 需要導入模塊: import coloredlogs [as 別名]
# 或者: from coloredlogs import DEFAULT_LEVEL_STYLES [as 別名]
def _update_log_color_set(self, logger):
        # level SPAM value is 5
        # level DEBUG value is 10
        coloredlogs.DEFAULT_FIELD_STYLES = {
            'hostname': {'color': 'magenta'},
            'programname': {'color': 'cyan'},
            'name': {'color': 'blue'},
            'levelname': {'color': 'black', 'bold': True},
            'asctime': {'color': 'magenta'}}

        if self.is_leader:
            coloredlogs.DEFAULT_LEVEL_STYLES = {
                'info': {},
                'notice': {'color': 'magenta'},
                'verbose': {'color': 'green'},
                'success': {'color': 'green', 'bold': True},
                'spam': {'color': 'cyan'},
                'critical': {'color': 'red', 'bold': True},
                'error': {'color': 'red'},
                'debug': {'color': 'blue'},
                'warning': {'color': 'yellow'}}
        else:
            coloredlogs.DEFAULT_LEVEL_STYLES = {
                'info': {},
                'notice': {'color': 'magenta'},
                'verbose': {'color': 'blue'},
                'success': {'color': 'green', 'bold': True},
                'spam': {'color': 'cyan'},
                'critical': {'color': 'red', 'bold': True},
                'error': {'color': 'red'},
                'debug': {'color': 'green'},
                'warning': {'color': 'yellow'}}

        coloredlogs.install(logger=logger,
                            fmt=self._log_format,
                            datefmt="%Y-%m-%d %H:%M:%S",
                            level=self._log_level) 
開發者ID:icon-project,項目名稱:loopchain,代碼行數:39,代碼來源:configuration.py

示例3: init_log

# 需要導入模塊: import coloredlogs [as 別名]
# 或者: from coloredlogs import DEFAULT_LEVEL_STYLES [as 別名]
def init_log(logger, loglevel=0, no_ansi=False):
    """
    Initializes logging.
    Prints logs to console with level defined by loglevel
    Also prints verbose log to the multiqc data directory if available.
    (multiqc_data/multiqc.log)

    Args:
        loglevel (str): Determines the level of the log output.
    """
    # File for logging
    global log_tmp_dir, log_tmp_fn
    log_tmp_dir = tempfile.mkdtemp()
    log_tmp_fn = os.path.join(log_tmp_dir, 'multiqc.log')

    # Logging templates
    debug_template = '[%(asctime)s] %(name)-50s [%(levelname)-7s]  %(message)s'
    info_template = '[%(levelname)-7s] %(module)15s : %(message)s'

    # Base level setup
    logger.setLevel(getattr(logging, 'DEBUG'))

    # Set up the console logging stream
    console = logging.StreamHandler()
    console.setLevel(getattr(logging, loglevel))
    level_styles = coloredlogs.DEFAULT_LEVEL_STYLES
    level_styles['debug'] = {'faint': True}
    if loglevel == 'DEBUG':
        if no_ansi or not sys.stderr.isatty():
            console.setFormatter(logging.Formatter(debug_template))
        else:
            console.setFormatter(coloredlogs.ColoredFormatter(fmt=debug_template, level_styles=level_styles))
    else:
        if no_ansi or not sys.stderr.isatty():
            console.setFormatter(logging.Formatter(info_template))
        else:
            console.setFormatter(coloredlogs.ColoredFormatter(fmt=info_template, level_styles=level_styles))
    logger.addHandler(console)

    # Now set up the file logging stream if we have a data directory
    file_handler = logging.FileHandler(log_tmp_fn, encoding='utf-8')
    file_handler.setLevel(getattr(logging, 'DEBUG')) # always DEBUG for the file
    file_handler.setFormatter(logging.Formatter(debug_template))
    logger.addHandler(file_handler) 
開發者ID:ewels,項目名稱:MultiQC,代碼行數:46,代碼來源:log.py


注:本文中的coloredlogs.DEFAULT_LEVEL_STYLES屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。