Python logging.NOTSET Examples
The following are 30
code examples of logging.NOTSET().
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
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: utils.py From Multi-Label-Text-Classification-for-Chinese with MIT License | 6 votes |
def init_logger(log_file=None, log_file_level=logging.NOTSET): if isinstance(log_file, Path): log_file = str(log_file) log_format = logging.Formatter("%(message)s") logger = logging.getLogger() logger.setLevel(logging.INFO) console_handler = logging.StreamHandler() console_handler.setFormatter(log_format) logger.handlers = [console_handler] if log_file: file_handler = logging.FileHandler(log_file) file_handler.setLevel(log_file_level) file_handler.setFormatter(log_format) logger.addHandler(file_handler) return logger
Example #2
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 #3
Source File: logging.py From recruit with Apache License 2.0 | 6 votes |
def create_logger(app): """Get the ``'flask.app'`` logger and configure it if needed. When :attr:`~flask.Flask.debug` is enabled, set the logger level to :data:`logging.DEBUG` if it is not set. If there is no handler for the logger's effective level, add a :class:`~logging.StreamHandler` for :func:`~flask.logging.wsgi_errors_stream` with a basic format. """ logger = logging.getLogger('flask.app') if app.debug and logger.level == logging.NOTSET: logger.setLevel(logging.DEBUG) if not has_level_handler(logger): logger.addHandler(default_handler) return logger
Example #4
Source File: config.py From jawfish with MIT License | 6 votes |
def _handle_existing_loggers(existing, child_loggers, disable_existing): """ When (re)configuring logging, handle loggers which were in the previous configuration but are not in the new configuration. There's no point deleting them as other threads may continue to hold references to them; and by disabling them, you stop them doing any logging. However, don't disable children of named loggers, as that's probably not what was intended by the user. Also, allow existing loggers to NOT be disabled if disable_existing is false. """ root = logging.root for log in existing: logger = root.manager.loggerDict[log] if log in child_loggers: logger.level = logging.NOTSET logger.handlers = [] logger.propagate = True else: logger.disabled = disable_existing
Example #5
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 #6
Source File: log.py From jbox with MIT License | 6 votes |
def log(self, level, msg, *args, **kwargs): """Delegate a log call to the underlying logger. The level here is determined by the echo flag as well as that of the underlying logger, and logger._log() is called directly. """ # inline the logic from isEnabledFor(), # getEffectiveLevel(), to avoid overhead. if self.logger.manager.disable >= level: return selected_level = self._echo_map[self.echo] if selected_level == logging.NOTSET: selected_level = self.logger.getEffectiveLevel() if level >= selected_level: self.logger._log(level, msg, args, **kwargs)
Example #7
Source File: core.py From jbox with MIT License | 6 votes |
def set_logging(self, level): level_list= ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"] if level in level_list: if(level == "CRITICAL"): logging.basicConfig(level=logging.CRITICAL) if (level == "ERROR"): logging.basicConfig(level=logging.ERROR) if (level == "WARNING"): logging.basicConfig(level=logging.WARNING) if (level == "INFO"): logging.basicConfig(level=logging.INFO) if (level == "DEBUG"): logging.basicConfig(level=logging.DEBUG) if (level == "NOTSET"): logging.basicConfig(level=logging.NOTSET) else: print ("set logging level failed ,the level is invalid.")
Example #8
Source File: _common.py From ungoogled-chromium with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_logger(initial_level=logging.INFO): """Gets the named logger""" logger = logging.getLogger(LOGGER_NAME) if logger.level == logging.NOTSET: logger.setLevel(initial_level) if not logger.hasHandlers(): console_handler = logging.StreamHandler() console_handler.setLevel(initial_level) format_string = '%(levelname)s: %(message)s' formatter = logging.Formatter(format_string) console_handler.setFormatter(formatter) logger.addHandler(console_handler) return logger
Example #9
Source File: test_azure_report_processor.py From koku with GNU Affero General Public License v3.0 | 6 votes |
def test_azure_process(self): """Test the processing of an uncompressed Azure file.""" counts = {} report_db = self.accessor report_schema = report_db.report_schema for table_name in self.report_tables: table = getattr(report_schema, table_name) with schema_context(self.schema): count = table.objects.count() counts[table_name] = count logging.disable(logging.NOTSET) # We are currently disabling all logging below CRITICAL in masu/__init__.py with self.assertLogs("masu.processor.azure.azure_report_processor", level="INFO") as logger: self.processor.process() self.assertIn("INFO:masu.processor.azure.azure_report_processor", logger.output[0]) self.assertIn("costreport_a243c6f2-199f-4074-9a2c-40e671cf1584.csv", logger.output[0]) for table_name in self.report_tables: table = getattr(report_schema, table_name) with schema_context(self.schema): count = table.objects.count() self.assertTrue(count > counts[table_name]) self.assertFalse(os.path.exists(self.test_report))
Example #10
Source File: _logging.py From faces with GNU General Public License v2.0 | 6 votes |
def setLevel(level): """Set logging level for the main logger.""" level = level.lower().strip() imdbpyLogger.setLevel(LEVELS.get(level, logging.NOTSET)) imdbpyLogger.log(imdbpyLogger.level, 'set logging threshold to "%s"', logging.getLevelName(imdbpyLogger.level)) #imdbpyLogger.setLevel(logging.DEBUG) # It can be an idea to have a single function to log and warn: #import warnings #def log_and_warn(msg, args=None, logger=None, level=None): # """Log the message and issue a warning.""" # if logger is None: # logger = imdbpyLogger # if level is None: # level = logging.WARNING # if args is None: # args = () # #warnings.warn(msg % args, stacklevel=0) # logger.log(level, msg % args)
Example #11
Source File: logging.py From ITDD with MIT License | 6 votes |
def init_logger(log_file=None, log_file_level=logging.NOTSET): log_format = logging.Formatter("[%(asctime)s %(levelname)s] %(message)s") logger = logging.getLogger() logger.setLevel(logging.INFO) console_handler = logging.StreamHandler() console_handler.setFormatter(log_format) logger.handlers = [console_handler] if log_file and log_file != '': file_handler = logging.FileHandler(log_file) file_handler.setLevel(log_file_level) file_handler.setFormatter(log_format) logger.addHandler(file_handler) return logger
Example #12
Source File: test_logger.py From python-sdk with Apache License 2.0 | 6 votes |
def test_adapt_logger__noop(self): """Test that adapt_logger returns a standard python logger from a NoOpLogger.""" noop_logger = _logger.NoOpLogger() standard_logger = _logger.adapt_logger(noop_logger) # adapt_logger knows about the loggers attached to this class. self.assertIs(noop_logger.logger, standard_logger) # Verify properties of the logger self.assertIsInstance(standard_logger, logging.Logger) self.assertEqual('optimizely.logger.NoOpLogger', standard_logger.name) self.assertEqual(logging.NOTSET, standard_logger.level) # Should have a single NullHandler (with a default formatter). self.assertEqual(1, len(standard_logger.handlers)) handler = standard_logger.handlers[0] self.assertIsInstance(handler, logging.NullHandler) self.assertEqual( '%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s:%(message)s', handler.formatter._fmt, )
Example #13
Source File: comfort.py From nata with MIT License | 6 votes |
def activate_logging(loggin_level: str = "info"): import logging if loggin_level == "notset": level = logging.NOTSET elif loggin_level == "debug": level = logging.DEBUG elif loggin_level == "info": level = logging.INFO elif loggin_level == "warning": level = logging.WARNING elif loggin_level == "error": level = logging.ERROR elif loggin_level == "critical": level = logging.CRITICAL else: raise ValueError( "Invalid loggin level provided! " + "Allowed are 'notset', 'debug', 'info', 'warning', 'error', " + "and 'critical'!" ) logging.basicConfig(format="%(levelname)s :: %(message)s", level=level)
Example #14
Source File: test_logging_config.py From airflow with Apache License 2.0 | 6 votes |
def reset_logging(): """Reset Logging""" manager = logging.root.manager manager.disabled = logging.NOTSET airflow_loggers = [ logger for logger_name, logger in manager.loggerDict.items() if logger_name.startswith('airflow') ] for logger in airflow_loggers: # pylint: disable=too-many-nested-blocks if isinstance(logger, logging.Logger): logger.setLevel(logging.NOTSET) logger.propagate = True logger.disabled = False logger.filters.clear() handlers = logger.handlers.copy() for handler in handlers: # Copied from `logging.shutdown`. try: handler.acquire() handler.flush() handler.close() except (OSError, ValueError): pass finally: handler.release() logger.removeHandler(handler)
Example #15
Source File: clioptions.py From clickhouse-mysql-data-reader with MIT License | 6 votes |
def log_level_from_string(log_level_string): """Convert string representation of a log level into logging.XXX constant""" if isinstance(log_level_string, str): level = log_level_string.upper() if level == 'CRITICAL': return logging.CRITICAL if level == 'ERROR': return logging.ERROR if level == 'WARNING': return logging.WARNING if level == 'INFO': return logging.INFO if level == 'DEBUG': return logging.DEBUG if level == 'NOTSET': return logging.NOTSET return logging.NOTSET
Example #16
Source File: LoggingHandler.py From sentence-transformers with Apache License 2.0 | 5 votes |
def __init__(self, level=logging.NOTSET): super().__init__(level)
Example #17
Source File: common.py From gluon-cv with Apache License 2.0 | 5 votes |
def default_logger(): """A logger used to output seed information to nosetests logs.""" logger = logging.getLogger(__name__) # getLogger() lookups will return the same logger, but only add the handler once. if not len(logger.handlers): handler = logging.StreamHandler(sys.stderr) handler.setFormatter(logging.Formatter('[%(levelname)s] %(message)s')) logger.addHandler(handler) if (logger.getEffectiveLevel() == logging.NOTSET): logger.setLevel(logging.INFO) return logger
Example #18
Source File: logger.py From python-client with Apache License 2.0 | 5 votes |
def setup_logger(level: int = logging.NOTSET) -> None: logger.propagate = False logger.setLevel(level) handler = logging.StreamHandler(stream=sys.stderr) logger.addHandler(handler) # global logger
Example #19
Source File: colin.py From colin with GNU General Public License v3.0 | 5 votes |
def _set_logging( logger_name="colin", level=logging.INFO, handler_class=logging.StreamHandler, handler_kwargs=None, format='%(asctime)s.%(msecs).03d %(filename)-17s %(levelname)-6s %(message)s', date_format='%H:%M:%S'): """ Set personal logger for this library. :param logger_name: str, name of the logger :param level: int, see logging.{DEBUG,INFO,ERROR,...}: level of logger and handler :param handler_class: logging.Handler instance, default is StreamHandler (/dev/stderr) :param handler_kwargs: dict, keyword arguments to handler's constructor :param format: str, formatting style :param date_format: str, date style in the logs """ if level != logging.NOTSET: logger = logging.getLogger(logger_name) logger.setLevel(level) # do not readd handlers if they are already present if not [x for x in logger.handlers if isinstance(x, handler_class)]: handler_kwargs = handler_kwargs or {} handler = handler_class(**handler_kwargs) handler.setLevel(level) formatter = logging.Formatter(format, date_format) handler.setFormatter(formatter) logger.addHandler(handler)
Example #20
Source File: conftest.py From indy-plenum with Apache License 2.0 | 5 votes |
def set_info_log_level(request): Logger.setLogLevel(logging.INFO) def reset(): Logger.setLogLevel(logging.NOTSET) request.addfinalizer(reset) # ####### SDK
Example #21
Source File: _internal.py From recruit with Apache License 2.0 | 5 votes |
def _log(type, message, *args, **kwargs): """Log into the internal werkzeug logger.""" global _logger if _logger is None: import logging _logger = logging.getLogger("werkzeug") if _logger.level == logging.NOTSET: _logger.setLevel(logging.INFO) # Only set up a default log handler if the # end-user application didn't set anything up. if not logging.root.handlers: handler = logging.StreamHandler() _logger.addHandler(handler) getattr(_logger, type)(message.rstrip(), *args, **kwargs)
Example #22
Source File: logging.py From ngraph-python with Apache License 2.0 | 5 votes |
def __init__(self, stream=sys.stdout, level=logging.NOTSET): self.stream = stream super(PBStreamHandler, self).__init__(level=level)
Example #23
Source File: __init__.py From dota2api with GNU General Public License v2.0 | 5 votes |
def _setup_logger(): import logging logging.basicConfig(level=logging.NOTSET) # Will log all return logging.getLogger(__name__)
Example #24
Source File: logger.py From python-sdk with Apache License 2.0 | 5 votes |
def __init__(self): self.logger = reset_logger( name='.'.join([__name__, self.__class__.__name__]), level=logging.NOTSET, handler=logging.NullHandler(), )
Example #25
Source File: logfail.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def __init__(self, level=logging.NOTSET, min_level=logging.WARNING): self._min_level = min_level super().__init__(level)
Example #26
Source File: utils.py From nagios-plugins-openshift with BSD 3-Clause "New" or "Revised" License | 5 votes |
def NagiosOutputFile(nagios_output): logging.basicConfig(level=logging.NOTSET, format="%(asctime)s %(message)s") if nagios_output is None: fh = sys.stdout else: fh = open(nagios_output, "w") ctx = _Reporter() logbuf = io.StringIO() rootlogger = logging.getLogger(name=None) try: handler = logging.StreamHandler(stream=logbuf) handler.setLevel(logging.INFO) handler.setFormatter(logging.Formatter(fmt="%(asctime)s %(message)s")) with contextlib.ExitStack() as exstack: # Add custom handler while check runs rootlogger.addHandler(handler) exstack.callback(rootlogger.removeHandler, handler) try: yield ctx.exit except Exception as err: logging.exception("Exception caught") ctx.exit(constants.STATE_CRITICAL, str(err)) finally: fh.write(ctx.exit_code_text) fh.write(" ") fh.write(", ".join(str(i) for i in _iter_any(ctx.output))) if ctx.metrics: fh.write(" | ") fh.write(" ".join(str(i) for i in _iter_any(ctx.metrics))) fh.write("\n") handler.flush() fh.write("\nLog messages:\n") fh.write(logbuf.getvalue()) fh.flush()
Example #27
Source File: utils.py From nagios-plugins-openshift with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setup_basic_logging(verbose): if verbose > 1: level = logging.NOTSET elif verbose: level = logging.INFO else: level = logging.CRITICAL logging.basicConfig(level=level)
Example #28
Source File: slogging.py From fragile with MIT License | 5 votes |
def __init__(self, level=logging.NOTSET): """Initialize a new StructuredHandler.""" super().__init__(level) self.local = threading.local()
Example #29
Source File: utils.py From raven-aiohttp with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, name, level=logging.NOTSET): self.name = name self.level = level self.records, self.msgs = [], [] self.logger = logging.getLogger(self.name) self.handler = TestHandler(self.records, self.msgs, level=self.level)
Example #30
Source File: test_logger.py From strawberryfields with Apache License 2.0 | 5 votes |
def reset_logging_module(): """Reset the logging specific configurations such as handlers or levels for the module specific loggers.""" for module in modules_contain_logging: logger = logging.getLogger(module.__name__) logger.handlers = [] logger.setLevel(logging.NOTSET)