本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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)
示例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
示例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
示例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
示例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
示例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]
示例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
示例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'
示例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'