Python logging.WARNING Examples
The following are 30
code examples of logging.WARNING().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
logging
, or try the search function
.
Example #1
Source File: config.py From Pytorch-Project-Template with MIT License | 12 votes |
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)
Example #2
Source File: getmetrics_hbase.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #3
Source File: log_conf.py From redditswapbot with GNU General Public License v3.0 | 6 votes |
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]
Example #4
Source File: loggingwrapper.py From CAMISIM with Apache License 2.0 | 6 votes |
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)
Example #5
Source File: loggingwrapper.py From CAMISIM with Apache License 2.0 | 6 votes |
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)
Example #6
Source File: loggingwrapper.py From CAMISIM with Apache License 2.0 | 6 votes |
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)
Example #7
Source File: __init__.py From everyclass-server with Mozilla Public License 2.0 | 6 votes |
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)
Example #8
Source File: client.py From microgear-python with ISC License | 6 votes |
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
Example #9
Source File: main.py From dogTorch with MIT License | 6 votes |
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)
Example #10
Source File: getmetrics_sysdig.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #11
Source File: getmetrics_hadoop.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #12
Source File: getmetrics_datadog.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #13
Source File: getlogs_k8s.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #14
Source File: getlogs_hadoop-mapreduce.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #15
Source File: getmessages_prometheus.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #16
Source File: insightagent-boilerplate.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #17
Source File: reportMetrics.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #18
Source File: collectdReportMetrics.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #19
Source File: getmetrics_sar.py From InsightAgent with Apache License 2.0 | 6 votes |
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
Example #20
Source File: log.py From FormulaNet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _get_color(self, level): if logging.WARNING <= level: return '\x1b[31m' elif logging.INFO <= level: return '\x1b[32m' else: return '\x1b[34m'
Example #21
Source File: ifLogger.py From InsightAgent with Apache License 2.0 | 5 votes |
def setloggerConfig(): # Get the root logger logger = logging.getLogger(__name__) # Have to set the root logger level, it defaults to logging.WARNING logger.setLevel(logging.DEBUG) # route INFO and DEBUG logging to stdout from stderr logging_handler_out = logging.StreamHandler(sys.stdout) logging_handler_out.setLevel(logging.DEBUG) logging_handler_out.addFilter(LessThanFilter(logging.WARNING)) logger.addHandler(logging_handler_out) logging_handler_err = logging.StreamHandler(sys.stderr) logging_handler_err.setLevel(logging.WARNING) logger.addHandler(logging_handler_err) return logger
Example #22
Source File: test_runtime.py From calmjs with GNU General Public License v2.0 | 5 votes |
def test_excution_missing_export_file(self): # as the null toolchain does not automatically provide one stub_stdouts(self) rt = runtime.ToolchainRuntime(toolchain.NullToolchain()) rt([]) self.assertEqual('', sys.stdout.getvalue()) stderr = sys.stderr.getvalue() self.assertIn('WARNING', stderr) self.assertIn("spec missing key 'export_target';", stderr)
Example #23
Source File: log.py From FormulaNet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _get_label(self, level): 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' else: return 'U'
Example #24
Source File: getmessages_mariadb.py From InsightAgent with Apache License 2.0 | 5 votes |
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( '{ts} [pid {pid}] {lvl} {mod}.{func}():{line} {msg}'.format( ts='%(asctime)s', pid='%(process)d', lvl='%(levelname)-8s', mod='%(module)s', func='%(funcName)s', line='%(lineno)d', msg='%(message)s'), ISO8601[0]) 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
Example #25
Source File: getmessages_mssql.py From InsightAgent with Apache License 2.0 | 5 votes |
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( '{ts} [pid {pid}] {lvl} {mod}.{func}():{line} {msg}'.format( ts='%(asctime)s', pid='%(process)d', lvl='%(levelname)-8s', mod='%(module)s', func='%(funcName)s', line='%(lineno)d', msg='%(message)s'), ISO8601[0]) 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
Example #26
Source File: driver_utils.py From toolium with Apache License 2.0 | 5 votes |
def _get_remote_node_url(self, remote_node): """Get grid-extras url of a node :param remote_node: remote node name :returns: grid-extras url """ logging.getLogger("requests").setLevel(logging.WARNING) gridextras_port = 3000 return 'http://{}:{}'.format(remote_node, gridextras_port)
Example #27
Source File: insightagent-boilerplate.py From InsightAgent with Apache License 2.0 | 5 votes |
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( '{ts} [pid {pid}] {lvl} {mod}.{func}():{line} {msg}'.format( ts='%(asctime)s', pid='%(process)d', lvl='%(levelname)-8s', mod='%(module)s', func='%(funcName)s', line='%(lineno)d', msg='%(message)s'), ISO8601[0]) 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
Example #28
Source File: script_runner.py From InsightAgent with Apache License 2.0 | 5 votes |
def setloggerConfig(): # Get the root logger logger = logging.getLogger(__name__) # Have to set the root logger level, it defaults to logging.WARNING logger.setLevel(logging.INFO) # route INFO and DEBUG logging to stdout from stderr logging_handler_out = logging.StreamHandler(sys.stdout) logging_handler_out.setLevel(logging.DEBUG) logging_handler_out.addFilter(LessThanFilter(logging.WARNING)) logger.addHandler(logging_handler_out) logging_handler_err = logging.StreamHandler(sys.stderr) logging_handler_err.setLevel(logging.WARNING) logger.addHandler(logging_handler_err) return logger
Example #29
Source File: utils.py From ffplayout-engine with GNU General Public License v3.0 | 5 votes |
def warning(self, msg): if self.level in ['INFO', 'WARNING']: self.check_if_new(msg)
Example #30
Source File: getmetrics_datadog.py From InsightAgent with Apache License 2.0 | 5 votes |
def get_parameters(): usage = "Usage: %prog [options]" parser = OptionParser(usage=usage) parser.add_option("-w", "--serverUrl", action="store", dest="serverUrl", help="Server Url") parser.add_option("-c", "--chunkLines", action="store", dest="chunkLines", help="Timestamps per chunk for historical data.") parser.add_option("-l", "--logLevel", action="store", dest="logLevel", help="Change log verbosity(WARNING: 0, INFO: 1, DEBUG: 2)") (options, args) = parser.parse_args() params = {} if options.serverUrl is None: params['serverUrl'] = 'https://app.insightfinder.com' else: params['serverUrl'] = options.serverUrl if options.chunkLines is None: params['chunkLines'] = 50 else: params['chunkLines'] = int(options.chunkLines) params['logLevel'] = logging.INFO if options.logLevel == '0': params['logLevel'] = logging.WARNING elif options.logLevel == '1': params['logLevel'] = logging.INFO elif options.logLevel >= '2': params['logLevel'] = logging.DEBUG return params