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


Python logging.WARNING屬性代碼示例

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


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

示例1: setup_logging

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def setup_logging(log_dir):
    log_file_format = "[%(levelname)s] - %(asctime)s - %(name)s - : %(message)s in %(pathname)s:%(lineno)d"
    log_console_format = "[%(levelname)s]: %(message)s"

    # Main logger
    main_logger = logging.getLogger()
    main_logger.setLevel(logging.INFO)

    console_handler = logging.StreamHandler()
    console_handler.setLevel(logging.INFO)
    console_handler.setFormatter(Formatter(log_console_format))

    exp_file_handler = RotatingFileHandler('{}exp_debug.log'.format(log_dir), maxBytes=10**6, backupCount=5)
    exp_file_handler.setLevel(logging.DEBUG)
    exp_file_handler.setFormatter(Formatter(log_file_format))

    exp_errors_file_handler = RotatingFileHandler('{}exp_error.log'.format(log_dir), maxBytes=10**6, backupCount=5)
    exp_errors_file_handler.setLevel(logging.WARNING)
    exp_errors_file_handler.setFormatter(Formatter(log_file_format))

    main_logger.addHandler(console_handler)
    main_logger.addHandler(exp_file_handler)
    main_logger.addHandler(exp_errors_file_handler) 
開發者ID:moemen95,項目名稱:Pytorch-Project-Template,代碼行數:25,代碼來源:config.py

示例2: init_plugins

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def init_plugins():
        """初始化日誌、錯誤追蹤、打點插件"""
        from everyclass.rpc import init as init_rpc
        from everyclass.common.flask import print_config

        # Sentry
        if plugin_available("sentry"):
            sentry.init_app(app=__app)
            sentry_handler = SentryHandler(sentry.client)
            sentry_handler.setLevel(logging.WARNING)
            logging.getLogger().addHandler(sentry_handler)

            init_rpc(sentry=sentry)
            logger.info('Sentry is inited because you are in {} mode.'.format(__app.config['CONFIG_NAME']))

        # metrics
        global statsd
        statsd = DogStatsd(namespace=f"{__app.config['SERVICE_NAME']}.{os.environ.get('MODE').lower()}",
                           use_default_route=True)

        init_rpc(logger=logger)

        print_config(__app, logger) 
開發者ID:everyclass,項目名稱:everyclass-server,代碼行數:25,代碼來源:__init__.py

示例3: set_level

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def set_level(self, level):
		"""
		Set the minimum level of messages to be logged.

		Level of Log Messages
		CRITICAL	50
		ERROR	40
		WARNING	30
		INFO	20
		DEBUG	10
		NOTSET	0

		@param level: minimum level of messages to be logged
		@type level: int or long

		@return: None
		@rtype: None
		"""
		assert level in self._levelNames

		list_of_handlers = self._logger.handlers
		for handler in list_of_handlers:
			handler.setLevel(level) 
開發者ID:CAMI-challenge,項目名稱:CAMISIM,代碼行數:25,代碼來源:loggingwrapper.py

示例4: set_log_level

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def set_log_level(self, verbose, debug):
		"""
		Simplified way to set log level.

		@attention verbose: Ignored if 'debug' true

		@param verbose: Display info messages and higher
		@type verbose: bool
		@param debug: Display debug messages and higher
		@type debug: bool

		@return: Nothing
		@rtype: None
		"""
		if debug:
			self._logger.set_level(self._logger.DEBUG)
		elif verbose:
			self._logger.set_level(self._logger.INFO)
		else:
			self._logger.set_level(self._logger.WARNING) 
開發者ID:CAMI-challenge,項目名稱:CAMISIM,代碼行數:22,代碼來源:loggingwrapper.py

示例5: set_level

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def set_level(self, level):
        """
        Set the minimum level of messages to be logged.

        Level of Log Messages
        CRITICAL    50
        ERROR    40
        WARNING    30
        INFO    20
        DEBUG    10
        NOTSET    0

        @param level: minimum level of messages to be logged
        @type level: int or long

        @return: None
        @rtype: None
        """
        assert level in self._levelNames

        list_of_handlers = self._logger.handlers
        for handler in list_of_handlers:
            handler.setLevel(level) 
開發者ID:CAMI-challenge,項目名稱:CAMISIM,代碼行數:25,代碼來源:loggingwrapper.py

示例6: create

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def create(gearkey,gearsecret, appid="", args = {}):
    if 'debugmode' in args:
        logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s %(levelname)-8s %(message)s',
                        datefmt='%d/%m/%Y %I:%M:%S %p',
                        )
    else:
        logging.basicConfig(level=logging.WARNING,
                        format='%(asctime)s %(levelname)-8s %(message)s',
                        datefmt='%d/%m/%Y %I:%M:%S %p',
                        )
    microgear.gearalias = args.get('alias',"")[0:16]
    if 'scope' in args:
        matchScope = re.match( r'^(\w+:[a-zA-Z\/]+,*)+$', args['scope'])
        if matchScope:
            microgear.scope = args["scope"]
        else:
            microgear.scope = ""
            logging.warning("Specify scope is not valid")

    microgear.gearkey = gearkey
    microgear.gearsecret = gearsecret
    microgear.appid = appid 
開發者ID:netpieio,項目名稱:microgear-python,代碼行數:25,代碼來源:client.py

示例7: setup_logging

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def setup_logging(filepath, verbose):
    logFormatter = logging.Formatter(
        '%(levelname)s %(asctime)-20s:\t %(message)s')
    rootLogger = logging.getLogger()
    if verbose:
        rootLogger.setLevel(logging.DEBUG)
    else:
        rootLogger.setLevel(logging.INFO)
    logging.getLogger('PIL').setLevel(logging.WARNING)

    # Setup the logger to write into file
    fileHandler = logging.FileHandler(filepath)
    fileHandler.setFormatter(logFormatter)
    rootLogger.addHandler(fileHandler)

    # Setup the logger to write into stdout
    consoleHandler = logging.StreamHandler(sys.stdout)
    consoleHandler.setFormatter(logFormatter)
    rootLogger.addHandler(consoleHandler) 
開發者ID:ehsanik,項目名稱:dogTorch,代碼行數:21,代碼來源:main.py

示例8: set_logger_config

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def set_logger_config(level):
    """Set up logging according to the defined log level"""
    # Get the root logger
    logger_obj = logging.getLogger(__name__)
    # Have to set the root logger level, it defaults to logging.WARNING
    logger_obj.setLevel(level)
    # route INFO and DEBUG logging to stdout from stderr
    logging_handler_out = logging.StreamHandler(sys.stdout)
    logging_handler_out.setLevel(logging.DEBUG)
    # create a logging format
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(process)d - %(threadName)s - %(levelname)s - %(message)s')
    logging_handler_out.setFormatter(formatter)
    logger_obj.addHandler(logging_handler_out)

    logging_handler_err = logging.StreamHandler(sys.stderr)
    logging_handler_err.setLevel(logging.WARNING)
    logger_obj.addHandler(logging_handler_err)
    return logger_obj 
開發者ID:insightfinder,項目名稱:InsightAgent,代碼行數:20,代碼來源:getmetrics_sysdig.py

示例9: set_logger_config

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def set_logger_config(level):
    """ set up logging according to the defined log level """
    # Get the root logger
    logger_obj = logging.getLogger(__name__)
    # Have to set the root logger level, it defaults to logging.WARNING
    logger_obj.setLevel(level)
    # route INFO and DEBUG logging to stdout from stderr
    logging_handler_out = logging.StreamHandler(sys.stdout)
    logging_handler_out.setLevel(logging.DEBUG)
    # create a logging format
    formatter = logging.Formatter('%(asctime)s [pid %(process)d] %(levelname)-8s %(module)s.%(funcName)s():%(lineno)d %(message)s')
    logging_handler_out.setFormatter(formatter)
    logger_obj.addHandler(logging_handler_out)

    logging_handler_err = logging.StreamHandler(sys.stderr)
    logging_handler_err.setLevel(logging.WARNING)
    logger_obj.addHandler(logging_handler_err)
    return logger_obj 
開發者ID:insightfinder,項目名稱:InsightAgent,代碼行數:20,代碼來源:getlogs_k8s.py

示例10: set_logger_config

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def set_logger_config(level):
    """Set up logging according to the defined log level"""
    # Get the root logger
    logger_obj = logging.getLogger(__name__)
    # Have to set the root logger level, it defaults to logging.INFO
    logger_obj.setLevel(level)
    # route INFO and DEBUG logging to stdout from stderr
    logging_handler_out = logging.StreamHandler(sys.stdout)
    logging_handler_out.setLevel(logging.DEBUG)
    # create a logging format
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(process)d - %(threadName)s - %(levelname)s - %(message)s')
    logging_handler_out.setFormatter(formatter)
    logger_obj.addHandler(logging_handler_out)

    logging_handler_err = logging.StreamHandler(sys.stderr)
    logging_handler_err.setLevel(logging.WARNING)
    logger_obj.addHandler(logging_handler_err)
    return logger_obj 
開發者ID:insightfinder,項目名稱:InsightAgent,代碼行數:20,代碼來源:reportMetrics.py

示例11: set_logger_config

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def set_logger_config(level):
    """ set up logging according to the defined log level """
    # Get the root logger
    logger_obj = logging.getLogger(__name__)
    # Have to set the root logger level, it defaults to logging.WARNING
    logger_obj.setLevel(level)
    # route INFO and DEBUG logging to stdout from stderr
    logging_handler_out = logging.StreamHandler(sys.stdout)
    logging_handler_out.setLevel(logging.DEBUG)
    # create a logging format
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(process)d - %(threadName)s - %(levelname)s - %(message)s')
    logging_handler_out.setFormatter(formatter)
    logger_obj.addHandler(logging_handler_out)

    logging_handler_err = logging.StreamHandler(sys.stderr)
    logging_handler_err.setLevel(logging.WARNING)
    logger_obj.addHandler(logging_handler_err)
    return logger_obj 
開發者ID:insightfinder,項目名稱:InsightAgent,代碼行數:20,代碼來源:insightagent-boilerplate.py

示例12: getLogger

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def getLogger(name=None):
		#configure logging
		LoggerManager._loggers[name] = logging.getLogger(name)
		LoggerManager._loggers[name].setLevel(logging.INFO)
		
		if logging_dest == 'mysql':
			db = {'host':mysql_hostname, 'port':3306, 'dbuser':mysql_username, 'dbpassword':mysql_password, 'dbname':mysql_database}
		
			sqlh = mySQLHandler.mySQLHandler(db)
			LoggerManager._loggers[name].addHandler(sqlh)
		else:
			fileh = logging.FileHandler('actions.log')
			fileh.setFormatter(logging.Formatter('%(asctime)s - %(module)s - %(message)s'))
			LoggerManager._loggers[name].addHandler(fileh)
		
		requests_log = logging.getLogger("requests")
		requests_log.setLevel(logging.WARNING)
		
		return LoggerManager._loggers[name] 
開發者ID:thelectronicnub,項目名稱:redditswapbot,代碼行數:21,代碼來源:log_conf.py

示例13: __init__

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def __init__(self, target, capacity):
        super().__init__(0)
        self.target = target
        self.capacity = capacity
        self.buffer = []
        self.handledbuffer = []
        self.lvl = logging.WARNING  # Default loglevel 
開發者ID:friendly-telegram,項目名稱:friendly-telegram,代碼行數:9,代碼來源:main.py

示例14: _get_color

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def _get_color(self, level):
        # pylint: disable= missing-docstring
        if logging.WARNING <= level:
            return '\x1b[31m'
        elif logging.INFO <= level:
            return '\x1b[32m'
        return '\x1b[34m' 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:9,代碼來源:log.py

示例15: _get_label

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import WARNING [as 別名]
def _get_label(self, level):
        # pylint: disable= missing-docstring
        if level == logging.CRITICAL:
            return 'C'
        elif level == logging.ERROR:
            return 'E'
        elif level == logging.WARNING:
            return 'W'
        elif level == logging.INFO:
            return 'I'
        elif level == logging.DEBUG:
            return 'D'
        return 'U' 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:15,代碼來源:log.py


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