Python set log level

60 Python code examples are found related to " set log level". 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.
Example 1
Source File: logging.py    From core with Apache License 2.0 6 votes vote down vote up
def setOverrideLogLevel(lvl):
    """
    Override all logger filter levels to include lvl and above.


    - Set root logger level
    - iterates all existing loggers and sets their log level to ``NOTSET``.

    Args:
        lvl (string): Log level name.
    """
    if lvl is None:
        return
    logging.info('Overriding log level globally to %s', lvl)
    lvl = getLevelName(lvl)
    global _overrideLogLevel # pylint: disable=global-statement
    _overrideLogLevel = lvl
    logging.getLogger('').setLevel(lvl)
    for loggerName in logging.Logger.manager.loggerDict:
        logger = logging.Logger.manager.loggerDict[loggerName]
        if isinstance(logger, logging.PlaceHolder):
            continue
        logger.setLevel(logging.NOTSET) 
Example 2
Source File: misc.py    From st2 with Apache License 2.0 6 votes vote down vote up
def set_log_level_for_all_loggers(level=logging.DEBUG):
    """
    Set a log level for all the loggers and handlers to the provided level.
    """
    root_logger = logging.getLogger()
    loggers = list(logging.Logger.manager.loggerDict.values())
    loggers += [root_logger]

    for logger in loggers:
        if not isinstance(logger, logging.Logger):
            continue

        logger = add_filters_for_logger(logger=logger, filters=GLOBAL_FILTERS)

        if logger.name in SPECIAL_LOGGERS:
            set_log_level_for_all_handlers(logger=logger, level=SPECIAL_LOGGERS.get(logger.name))
        else:
            set_log_level_for_all_handlers(logger=logger, level=level)

    return loggers 
Example 3
Source File: tools.py    From python-insteonplm with MIT License 6 votes vote down vote up
def do_set_log_level(self, arg):
        """Set the log level.

        Usage:
            set_log_level i|v
        Parameters:
            log_level: i - info | v - verbose

        """
        if arg in ["i", "v"]:
            _LOGGING.info("Setting log level to %s", arg)
            if arg == "i":
                _LOGGING.setLevel(logging.INFO)
                _INSTEONPLM_LOGGING.setLevel(logging.INFO)
            else:
                _LOGGING.setLevel(logging.DEBUG)
                _INSTEONPLM_LOGGING.setLevel(logging.DEBUG)
        else:
            _LOGGING.error("Log level value error.")
            self.do_help("set_log_level") 
Example 4
Source File: common.py    From rasa-for-botfront with Apache License 2.0 6 votes vote down vote up
def set_log_level(log_level: Optional[int] = None):
    """Set log level of Rasa and Tensorflow either to the provided log level or
    to the log level specified in the environment variable 'LOG_LEVEL'. If none is set
    a default log level will be used."""
    import logging

    if not log_level:
        log_level = os.environ.get(ENV_LOG_LEVEL, DEFAULT_LOG_LEVEL)
        log_level = logging.getLevelName(log_level)

    logging.getLogger("rasa").setLevel(log_level)

    update_tensorflow_log_level()
    update_asyncio_log_level()
    update_apscheduler_log_level()
    update_socketio_log_level()

    os.environ[ENV_LOG_LEVEL] = logging.getLevelName(log_level) 
Example 5
Source File: utils.py    From neurodocker with Apache License 2.0 6 votes vote down vote up
def set_log_level(level):
    """Set logger verbosity.

    Parameters
    ----------
    level: {'debug', 'info', 'warning', 'error', 'critical}
        The level at which to print messages. Case-insensitive.
    """
    logging_levels = {
        'DEBUG': logging.DEBUG,
        'INFO': logging.INFO,
        'WARNING': logging.WARNING,
        'ERROR': logging.ERROR,
        'CRITICAL': logging.CRITICAL
    }
    try:
        level = logging_levels[level.upper()]
        logger.setLevel(level)
    except KeyError:
        raise ValueError("invalid level '{}'".format(level)) 
Example 6
Source File: utils.py    From pyglmnet with MIT License 6 votes vote down vote up
def set_log_level(verbose):
    """Convenience function for setting the log level.

    Parameters
    ----------
    verbose : bool, str, int, or None
        The verbosity of messages to print. If a str, it can be either DEBUG,
        INFO, WARNING, ERROR, or CRITICAL. Note that these are for
        convenience and are equivalent to passing in logging.DEBUG, etc.
        For bool, True is the same as 'INFO', False is the same as 'WARNING'.
    """
    if isinstance(verbose, bool):
        if verbose is True:
            verbose = 'INFO'
        else:
            verbose = 'WARNING'
    if isinstance(verbose, str):
        verbose = verbose.upper()
        logging_types = dict(DEBUG=logging.DEBUG, INFO=logging.INFO,
                             WARNING=logging.WARNING, ERROR=logging.ERROR,
                             CRITICAL=logging.CRITICAL)
        if verbose not in logging_types:
            raise ValueError('verbose must be of a valid type')
        verbose = logging_types[verbose]
    logger.setLevel(verbose) 
Example 7
Source File: io.py    From yasa with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def set_log_level(verbose=None):
    """Convenience function for setting the logging level.

    This function comes from the PySurfer package. See :
    https://github.com/nipy/PySurfer/blob/master/surfer/utils.py

    Parameters
    ----------
    verbose : bool, str, int, or None
        The verbosity of messages to print. If a str, it can be either
        PROFILER, DEBUG, INFO, WARNING, ERROR, or CRITICAL.
    """
    logger = logging.getLogger('yasa')
    if isinstance(verbose, bool):
        verbose = 'INFO' if verbose else 'WARNING'
    if isinstance(verbose, str):
        if (verbose.upper() in LOGGING_TYPES):
            verbose = verbose.upper()
            verbose = LOGGING_TYPES[verbose]
            logger.setLevel(verbose)
        else:
            raise ValueError("verbose must be in "
                             "%s" % ', '.join(LOGGING_TYPES)) 
Example 8
Source File: logger.py    From devito with MIT License 6 votes vote down vote up
def set_log_level(level, comm=None):
    """
    Set the log level of the Devito logger.

    Parameters
    ----------
    level : int
        The logging level. Accepted values are: ``DEBUG, PERF, INFO, WARNING,
        ERROR, CRITICAL``.
    comm : MPI communicator, optional
        An MPI communicator the logger should be collective over. If provided, only
        rank-0 on that communicator will write to the registered handlers, other
        ranks will use a `logging.NullHandler`.  By default, ``comm`` is set
        to ``None``, so all ranks will use the default handlers.  This could be
        used, for example, if one wants to log to one file per rank.
    """
    if level not in logger_registry:
        raise ValueError("Illegal logging level %s" % level)

    if comm is not None:
        if comm.rank != 0:
            logger.removeHandler(stream_handler)
            logger.addHandler(logging.NullHandler())

    logger.setLevel(level) 
Example 9
Source File: thermostat.py    From thermostat with MIT License 6 votes vote down vote up
def setLogLevel( msg ):
	global logLevel

	if LOG_LEVELS.get( msg.payload ):
		log( LOG_LEVEL_STATE, CHILD_DEVICE_NODE, MSG_SUBTYPE_CUSTOM + "/loglevel", "LogLevel set to: " + msg.payload ) 

		logLevel = LOG_LEVELS.get( msg.payload, logLevel )
	else:
		log( LOG_LEVEL_ERROR, CHILD_DEVICE_NODE, MSG_SUBTYPE_CUSTOM + "/loglevel", "Invalid LogLevel: " + msg.payload ) 


##############################################################################
#                                                                            #
#       Thermostat Implementation                                            #
#                                                                            #
##############################################################################

# Main furnace/AC system control function: 
Example 10
Source File: service.py    From forseti-security with Apache License 2.0 6 votes vote down vote up
def SetLogLevel(self, request, _):
        """Set log level.

        Args:
            request (SetLogLevelRequest): The grpc request object.
            _ (object): Context of the request.

        Returns:
            SetLogLevelReply: The SetLogLevelReply grpc object.
        """
        err_msg = ''

        try:
            LOGGER.info('Setting log level, log_level = %s',
                        request.log_level)
            logger.set_logger_level(logger.LOGLEVELS[request.log_level])
        except Exception as e:  # pylint: disable=broad-except
            LOGGER.exception(e)
            err_msg = str(e)

        is_success = not err_msg

        return server_pb2.SetLogLevelReply(is_success=is_success,
                                           error_message=err_msg) 
Example 11
Source File: _filter.py    From Safejumper-for-Desktop with GNU General Public License v2.0 6 votes vote down vote up
def setLogLevelForNamespace(self, namespace, level):
        """
        Sets the log level for a logging namespace.

        @param namespace: A logging namespace.
        @type namespace: L{str} (native string)

        @param level: The log level for the given namespace.
        @type level: L{LogLevel}
        """
        if level not in LogLevel.iterconstants():
            raise InvalidLogLevelError(level)

        if namespace:
            self._logLevelsByNamespace[namespace] = level
        else:
            self._logLevelsByNamespace[None] = level 
Example 12
Source File: logger.py    From pypyr-cli with Apache License 2.0 6 votes vote down vote up
def set_up_notify_log_level():
    """Add up a global notify severity to the python logging package.

    NOTIFY severity is logging level between INFO and WARNING.
    By default it outputs only echo step and step name
    with description.
    """

    # could (should?) be checking hasattr like so:
    # hasattr(logging, levelName):
    # hasattr(logging, methodName):
    # hasattr(logging.getLoggerClass(), methodName):
    # but this extra check is arguably *more* overhead than just assigning it?
    logging.addLevelName(NOTIFY, "NOTIFY")
    logging.NOTIFY = NOTIFY
    logging.getLoggerClass().notify = notify 
Example 13
Source File: app.py    From clgen with GNU General Public License v3.0 6 votes vote down vote up
def SetLogLevel(level: int) -> None:
  """Sets the logging verbosity.

  Causes all messages of level <= v to be logged, and all messages of level > v
  to be silently discarded.

  Args:
    level: the verbosity level as an integer.
  """
  logging.SetLogLevel(level)


# Flags functions.

# This is a set of module ids for the modules that disclaim key flags.
# This module is explicitly added to this set so that we never consider it to
# define key flag. 
Example 14
Source File: loggingwrapper.py    From CAMISIM with Apache License 2.0 6 votes vote down vote up
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 15
Source File: _logger.py    From tcconfig with MIT License 6 votes vote down vote up
def set_log_level(log_level):
    if log_level == "DEBUG":
        log_format = (
            "<level>{level: <8}</level> | "
            "<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>"
        )
    else:
        log_format = "<level>[{level}]</level> {message}"

    logger.remove()
    logger.add(sys.stderr, colorize=True, format=log_format, level=log_level)

    if log_level == "QUIET":
        set_logger(is_enable=False)
    else:
        set_logger(is_enable=True) 
Example 16
Source File: logger.py    From anchore-engine with Apache License 2.0 6 votes vote down vote up
def set_log_level(new_log_level, log_to_stdout=False, log_to_db=False):
    """
    Set log level for twisted logging
    :param new_log_level: a string name of log level, e.g. 'INFO', 'DEBUG'
    :param log_to_stdout:
    :param log_to_db:
    :return:
    """
    global log_level, log_level_map, _log_to_stdout, _log_to_db

    # Don't require the level strings to be upper, normalize it here
    new_log_level = new_log_level.upper()

    if new_log_level in log_level_map:
        log_level = log_level_map[new_log_level]

    _log_to_stdout = log_to_stdout
    _log_to_db = log_to_db 
Example 17
Source File: dm_xnat_rename.py    From datman with Apache License 2.0 6 votes vote down vote up
def set_log_level(arguments):
    debug = arguments['--debug']
    verbose = arguments['--verbose']
    quiet = arguments['--quiet']

    # The xnat module is noisy, its default level should be 'error'
    xnat_logger = logging.getLogger("datman.xnat")
    xnat_logger.setLevel(logging.ERROR)

    if debug:
        logger.setLevel(logging.DEBUG)
        xnat_logger.setLevel(logging.DEBUG)
    if verbose:
        logger.setLevel(logging.INFO)
        xnat_logger.setLevel(logging.INFO)
    if quiet:
        logger.setLevel(logging.ERROR) 
Example 18
Source File: scalyr_logging.py    From scalyr-agent-2 with Apache License 2.0 6 votes vote down vote up
def set_log_level(level):
    """Sets the log level that should be used by all AgentLogger instances.

    This method is thread-safe.

    @param level: The level, in the logging units by the logging package, such as logging.INFO, logging.DEBUG, etc.
        You can also use one of the Scalyr debug levels, such as DEBUG_LEVEL_0, DEBUG_LEVEL_1, etc.
    @type level: int
    """
    __log_manager__.set_log_level(level)


#
# _srcfile is used when walking the stack to check when we've got the first
# caller stack frame.  This is copied from the logging/__init__.py
# 
Example 19
Source File: client.py    From QTS_Research with MIT License 6 votes vote down vote up
def setServerLogLevel(self, logLevel:int):
        """The default detail level is ERROR. For more details, see API
        Logging."""

        self.logRequest(current_fn_name(), vars())

        if not self.isConnected():
            self.wrapper.error(NO_VALID_ID, NOT_CONNECTED.code(),
                               NOT_CONNECTED.msg())
            return

        VERSION = 1

        msg = make_field(OUT.SET_SERVER_LOGLEVEL) \
            + make_field(VERSION) \
            + make_field(logLevel)

        self.sendMsg(msg) 
Example 20
Source File: bioio.py    From toil with Apache License 2.0 6 votes vote down vote up
def setLogLevel(level, logger=None):
    """
    Sets the log level to a given string level (like "INFO"). Operates on the
    root logger by default, but another logger can be specified instead.
    """
    if logger is None:
        logger = rootLogger
    level = level.upper()
    if level == "OFF": level = "CRITICAL"
    # Note that getLevelName works in both directions, numeric to textual and textual to numeric
    numericLevel = logging.getLevelName(level)
    assert logging.getLevelName(numericLevel) == level
    logger.setLevel(numericLevel)
    # There are quite a few cases where we expect AWS requests to fail, but it seems
    # that boto handles these by logging the error *and* raising an exception. We
    # don't want to confuse the user with those error messages.
    logging.getLogger( 'boto' ).setLevel( logging.CRITICAL ) 
Example 21
Source File: core.py    From gitlabform with MIT License 6 votes vote down vote up
def set_log_level(self, tests=False):

        logging.basicConfig()
        level = logging.WARNING
        if self.verbose:
            level = logging.INFO
        elif self.debug:
            level = logging.DEBUG
        logging.getLogger().setLevel(level)

        if not tests:
            fmt = logging.Formatter("%(message)s")
            logging.getLogger().handlers[0].setFormatter(fmt)
        else:
            # disable printing to stdout/err because pytest will catch it anyway
            handler = logging.getLogger().handlers[0]
            logging.getLogger().removeHandler(handler) 
Example 22
Source File: logging.py    From flexx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def set_log_level(level, match=None):
    """Set the logging level and match filter

    Parameters:
        level (str, int): The verbosity of messages to print.
            If a str, it can be either DEBUG, INFO, WARNING, ERROR, or
            CRITICAL. Note that these are for convenience and are equivalent
            to passing in logging.DEBUG, etc.
        match (str, regexp, None): String to match. Only those messages
            that contain ``match`` as a substring (and has the
            appropriate ``level``) will be displayed. Match can also be
            a compiled regexp.

    Notes
    -----
    If level is DEBUG, the method emitting the log message will be
    prepended to each log message. Note that if ``level`` is DEBUG or
    if the ``match`` option is used, a small overhead is added to each
    logged message.
    """
    if isinstance(level, str):
        level = level.lower()
        if level not in logging_types:
            raise ValueError('Invalid argument "%s"' % level)
        level = logging_types[level]
    elif not isinstance(level, int):
        raise TypeError('log level must be an int or string')
    logger.setLevel(level)
    _filter.match = match
    _formatter.prepend_caller = level <= logging.DEBUG 
Example 23
Source File: admin_pb2_grpc.py    From fabric-sdk-py with Apache License 2.0 5 votes vote down vote up
def SetModuleLogLevel(self, request, context):
    # missing associated documentation comment in .proto file
    pass
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!') 
Example 24
Source File: core.py    From pandas_redshift with MIT License 5 votes vote down vote up
def set_log_level(level, mask_secrets=True):
    log_level_map = {
        'debug': logging.DEBUG,
        'info': logging.INFO,
        'warn': logging.WARN,
        'error': logging.ERROR
    }
    logging_config['logger_level'] = log_level_map[level]
    logger = logging.getLogger(__name__)
    logger.setLevel(logging_config['logger_level'])
    logging_config['mask_secrets'] = mask_secrets 
Example 25
Source File: core.py    From pyexiv2 with GNU General Public License v3.0 5 votes vote down vote up
def set_log_level(level=2):
    """
    Set the level of handling logs. There are five levels of handling logs:
        0 : debug
        1 : info
        2 : warn
        3 : error
        4 : mute
    """
    if level in [0, 1, 2, 3, 4]:
        exiv2api.set_log_level(level)
    else:
        raise ValueError('Invalid log level.') 
Example 26
Source File: iofun.py    From insteon-terminal with The Unlicense 5 votes vote down vote up
def setLogLevel(level):
	"""setLogLevel(level) changes the log level to level, where level is a string (ERROR, WARN, INFO, DEBUG, and TRACE) """
	
	logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)
	levels = {
				'ERROR': Level.ERROR,
				'WARN': Level.WARN,
				'INFO': Level.INFO,
				'DEBUG': Level.DEBUG,
				'TRACE': Level.TRACE
			  }
	l = levels[level.upper()]
	logger.setLevel(l) 
Example 27
Source File: logutil.py    From orca with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def set_log_level(level):
    """
    Set the logging level for Orca.

    Parameters
    ----------
    level : int
        A supporting logging level. Use logging constants like logging.DEBUG.

    """
    logging.getLogger('orca').setLevel(level) 
Example 28
Source File: logging.py    From FlowKit with Mozilla Public License 2.0 5 votes vote down vote up
def set_log_level(logger_name: str, log_level: str) -> None:
    """
    Set log level for logger `flowmachine.debug`.

    Parameters
    ----------
    logger_name : str
        Name of the logger for which to set the log level.
    log_level : str
        Level to emit logs at. This must be one of the standard
        pre-defined log levels ("DEBUG", "INFO", "ERROR", etc.).
        If an invalid log level is passed, "ERROR" will be used.

    Returns
    -------
    None
    """
    user_provided_log_level = log_level.upper()
    logger = logging.getLogger(logger_name)
    try:
        logger.setLevel(user_provided_log_level)
        true_log_level = user_provided_log_level
        user_provided_log_level_is_valid = True
    except ValueError:
        true_log_level = "ERROR"
        user_provided_log_level_is_valid = False
        logger.setLevel(true_log_level)

    for handler in logger.handlers:
        handler.setLevel(true_log_level)

    if not user_provided_log_level_is_valid:
        logger.error(
            f"Invalid user-provided log level: '{user_provided_log_level}', using '{true_log_level}' instead."
        )
    logger.info(f"Log level for logger '{logger_name}' set to '{true_log_level}'.") 
Example 29
Source File: logger.py    From pkuseg with Apache License 2.0 5 votes vote down vote up
def set_log_level(log_level):
        if not LOG_LEVEL_DICT.has_key(log_level):
            print('Invalid logging level: {}'.format(Logger.log_level))
            return

        Logger.log_level = log_level
        Logger.init() 
Example 30
Source File: modjy_log.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def set_log_level(self, level_string):
        try:
            self.log_level = levels_dict[level_string]
        except KeyError:
            raise BadParameter("Invalid log level: '%s'" % level_string) 
Example 31
Source File: misc.py    From st2 with Apache License 2.0 5 votes vote down vote up
def set_log_level_for_all_handlers(logger, level=logging.DEBUG):
    """
    Set a log level for all the handlers on the provided logger.
    """
    logger.setLevel(level)

    handlers = logger.handlers
    for handler in handlers:
        handler.setLevel(level)

    return logger 
Example 32
Source File: log.py    From lang2program with Apache License 2.0 5 votes vote down vote up
def set_log_level(level):
    """Set the log-level of the root logger of the logging module.

    Args:
        level: can be an integer such as 30 (logging.WARN), or a string such as 'WARN'
    """
    if isinstance(level, str):
        level = logging._levelNames[level]

    logger = logging.getLogger()  # gets root logger
    logger.setLevel(level) 
Example 33
Source File: utils.py    From manheim-c7n-tools with Apache License 2.0 5 votes vote down vote up
def set_log_level_format(log, level, format):
    """
    Set log level and format.

    :param log: the logger to set level and format on
    :type log: logging.Logger
    :param level: logging level; see the :py:mod:`logging` constants.
    :type level: int
    :param format: logging formatter format string
    :type format: str
    """
    formatter = logging.Formatter(fmt=format)
    log.handlers[0].setFormatter(formatter)
    log.setLevel(level) 
Example 34
Source File: utils.py    From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def set_log_level(level, name="cleverhans"):
    """
    Sets the threshold for the cleverhans logger to level
    :param level: the logger threshold. You can find values here:
                  https://docs.python.org/2/library/logging.html#levels
    :param name: the name used for the cleverhans logger
    """
    logging.getLogger(name).setLevel(level) 
Example 35
Source File: utils.py    From cleverhans with MIT License 5 votes vote down vote up
def set_log_level(level, name="cleverhans"):
  """
  Sets the threshold for the cleverhans logger to level
  :param level: the logger threshold. You can find values here:
                https://docs.python.org/2/library/logging.html#levels
  :param name: the name used for the cleverhans logger
  """
  logging.getLogger(name).setLevel(level) 
Example 36
Source File: util.py    From chicksexer with MIT License 5 votes vote down vote up
def set_log_level(logger, log_level: int):
    """Set log level for the given logger."""
    logger.setLevel(log_level)
    for handler in logger.handlers:
        handler.setLevel(log_level) 
Example 37
Source File: khaiii.py    From khaiii with Apache License 2.0 5 votes vote down vote up
def set_log_level(self, name: str, level: str):
        """
        khaiii_set_log_level() dev API
        Args:
            name:  로거 이름
            level:  로거 레벨. trace, debug, info, warn, err, critical
        """
        ret = self._lib.khaiii_set_log_level(name.encode('UTF-8'), level.encode('UTF-8'))
        if ret < 0:
            raise KhaiiiExcept(self._last_error()) 
Example 38
Source File: gateway_logging_configuration_service.py    From WavesGatewayFramework with MIT License 5 votes vote down vote up
def set_log_level(self, level, loggers: Optional[Union[List[str], str]] = None):
        """
        Adjusts the log level for all known loggers or specific ones if an additional parameter is added.
        """
        to_be_adjusted = list()  # type: List[Logger]

        if loggers is None:
            for logger in self._managed_loggers:
                to_be_adjusted.append(logger)

            to_be_adjusted.append(self._logger)
        elif isinstance(loggers, str):
            if loggers == self._logger.name:
                to_be_adjusted.append(self._logger)

            for logger in self._managed_loggers:
                if logger.name == loggers:
                    to_be_adjusted.append(logger)
        else:
            if self._logger.name in loggers:
                to_be_adjusted.append(self._logger)

            for logger in self._managed_loggers:
                if logger.name in loggers:
                    to_be_adjusted.append(logger)

        for logger in to_be_adjusted:
            logger.setLevel(level)

        for handler in self._logging_handlers:
            handler.setLevel(level) 
Example 39
Source File: Log.py    From broc with Apache License 2.0 5 votes vote down vote up
def setLogLevel(self, lev):
            """
            Description : set log file level.The log message lower than this level will not be printed.
            Args : lev : log level will be set.Value is [0-5],0 will not print any log message, 5 will print all log message
            Return : NULL 
            """
            self.config_level = lev 
Example 40
Source File: __init__.py    From treadmill with Apache License 2.0 5 votes vote down vote up
def set_log_level(log_level):
    """Set loglevel for all treadmill modules
    """
    # pylint: disable=consider-iterating-dictionary
    # yes, we need to iterate keys
    logger_keys = [
        lk for lk in logging.Logger.manager.loggerDict.keys()
        if '.' not in lk and lk[:9] == 'treadmill'
    ]

    logging.getLogger().setLevel(log_level)
    for logger_key in logger_keys:
        logging.getLogger(logger_key).setLevel(log_level) 
Example 41
Source File: deferred.py    From python-compat-runtime with Apache License 2.0 5 votes vote down vote up
def set_log_level(log_level):
  """Sets the log level deferred will log to in normal circumstances.

  Args:
    log_level: one of logging log levels, e.g. logging.DEBUG, logging.INFO, etc.
  """
  global _DEFAULT_LOG_LEVEL
  _DEFAULT_LOG_LEVEL = log_level 
Example 42
Source File: log.py    From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
def set_log_level(log_level):
    """
    Set log level.
    """

    if isinstance(log_level, basestring):
        if log_level.upper() == "DEBUG":
            stclog.Logs().set_level(logging.DEBUG)
        elif log_level.upper() == "INFO":
            stclog.Logs().set_level(logging.INFO)
        elif log_level.upper() == "WARN":
            stclog.Logs().set_level(logging.WARN)
        elif log_level.upper() == "ERROR":
            stclog.Logs().set_level(logging.ERROR)
        elif log_level.upper() == "WARNING":
            stclog.Logs().set_level(logging.WARNING)
        elif log_level.upper() == "CRITICAL":
            stclog.Logs().set_level(logging.CRITICAL)
        else:
            stclog.Logs().set_level(logging.INFO)
    elif isinstance(log_level, int):
        if log_level in [logging.DEBUG, logging.INFO, logging.ERROR,
                         logging.WARN, logging.WARNING, logging.CRITICAL]:
            stclog.Logs().set_level(log_level)
        else:
            stclog.Logs().set_level(logging.INFO)
    else:
        stclog.Logs().set_level(logging.INFO)


# Global logger 
Example 43
Source File: logging.py    From StrepHit with GNU General Public License v3.0 5 votes vote down vote up
def setLogLevel(module, level):
    """ Sets the log level used to log messages from the given module """
    if level in LEVELS:
        module = '' if module == 'root' else module
        logging.getLogger(module).setLevel(level) 
Example 44
Source File: client.py    From forseti-security with Apache License 2.0 5 votes vote down vote up
def set_log_level(self, log_level):
        """Sets the log level.

        Args:
            log_level (str): The updated log level.

        Returns:
            proto: the returned proto message.
        """
        request = server_pb2.SetLogLevelRequest(log_level=log_level)
        return self.stub.SetLogLevel(request) 
Example 45
Source File: utils.py    From biggraphite with Apache License 2.0 5 votes vote down vote up
def set_log_level(settings):
    """Set logs level according to settings."""
    logger = logging.getLogger("biggraphite")
    # Install a handler if there are none.
    if not logger.handlers:
        handler = logging.StreamHandler()
        handler.setFormatter(
            logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")
        )
        logger.addHandler(handler)
    logger.setLevel(settings.get("loglevel", DEFAULT_LOG_LEVEL)) 
Example 46
Source File: logger.py    From kiwi with GNU General Public License v3.0 5 votes vote down vote up
def setLogLevel(self, level):
        """
        Set custom log level for all console handlers

        :param int level: log level number
        """
        self.log_level = level
        for handler_type in self.console_handlers:
            self.console_handlers[handler_type].setLevel(level) 
Example 47
Source File: logger.py    From komodo-wakatime with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def set_log_level(logger, args):
    level = logging.WARN
    if args.verbose:
        level = logging.DEBUG
    logger.setLevel(level) 
Example 48
Source File: hubs_api.py    From web2board with GNU Lesser General Public License v3.0 5 votes vote down vote up
def set_log_level(self, logLevel):
                """
                :rtype : Future
                """
                args = list()
                args.append(logLevel)
                id_ = self._get_next_message_id()
                body = {"hub": self.hub_name, "function": "set_log_level", "args": args, "ID": id_}
                future = self.ws_client.get_future(id_)
                send_return_obj = self.ws_client.send(self._serialize_object(body))
                if isinstance(send_return_obj, Future):
                    return send_return_obj
                return future 
Example 49
Source File: log.py    From teleport with Apache License 2.0 5 votes vote down vote up
def set_library_log_detail_level(detail):
    if detail in DETAIL_LEVELS:
        global _detail_level
        _detail_level = detail
        if log_enabled(ERROR):
            log(ERROR, 'detail level set to ' + get_detail_level_name(_detail_level))
    else:
        if log_enabled(ERROR):
            log(ERROR, 'unable to set log detail level to <%s>', detail)
        raise ValueError('invalid library log detail level') 
Example 50
Source File: log.py    From teleport with Apache License 2.0 5 votes vote down vote up
def set_library_log_activation_level(logging_level):
    if isinstance(logging_level, int):
        global _logging_level
        _logging_level = logging_level
    else:
        if log_enabled(ERROR):
            log(ERROR, 'invalid library log activation level <%s> ', logging_level)
        raise ValueError('invalid library log activation level') 
Example 51
Source File: logger.py    From geocube with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def set_log_level(level=None):
    """
    Sets the log level of the logger.

    Parameters
    ----------
    level: string, optional, default=None
        Level of logging; whichever level is chosen all higher levels
        will be logged. See: https://docs.python.org/2/library/logging.html#levels
    """
    if level is not None:
        _LOGGER.setLevel(level)
    else:
        _LOGGER.setLevel(logging.WARNING) 
Example 52
Source File: app_config.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def set_log_level(self, new_log_level_str: str):
        """
        Method called when log level has been changed by the user. New log
        :param new_log_level: new log level (symbol as INFO,WARNING,etc) to be set.
        """
        if self.log_level_str != new_log_level_str:
            ll_sav = self.log_level_str
            lg = logging.getLogger()
            if lg:
                lg.setLevel(new_log_level_str)
                if ll_sav:
                    logging.info('Changed log level to: %s' % new_log_level_str)
            self.log_level_str = new_log_level_str 
Example 53
Source File: rdEditor.py    From rdeditor with GNU Lesser General Public License v3.0 5 votes vote down vote up
def setLogLevel(self):
        loglevel = self.sender().objectName().split(':')[-1].upper()
        self.editor.logger.setLevel(loglevel)



    # Function to create actions for menus 
Example 54
Source File: cliutils.py    From biweeklybudget with GNU Affero General Public License v3.0 5 votes vote down vote up
def set_log_level_format(logger, level, format):
    """
    Set logger level and format.

    :param logger: the logger object to set on
    :type logger: logging.Logger
    :param level: logging level; see the :py:mod:`logging` constants.
    :type level: int
    :param format: logging formatter format string
    :type format: str
    """
    formatter = logging.Formatter(fmt=format)
    logger.handlers[0].setFormatter(formatter)
    logger.setLevel(level) 
Example 55
Source File: repl.py    From pyringe with Apache License 2.0 5 votes vote down vote up
def SetLogLevel(self, level):
    """Set log level. Corresponds to levels from logging module."""
    # This is mostly here to jog people into enabling logging without
    # requiring them to have looked at the pyringe code.
    return logging.getLogger().setLevel(level) 
Example 56
Source File: loggers.py    From i3-xfce with GNU Lesser General Public License v3.0 5 votes vote down vote up
def set_log_level(lvl):
  """
  Function to set log level
  """
  ROOTLOGGER.setLevel(lvl) 
Example 57
Source File: slackpy.py    From slackpy with MIT License 5 votes vote down vote up
def set_log_level(self, lv):

        if lv in LOG_LEVELS:
            self.log_level = lv

        else:
            raise ValueError('argument lv is invalid. Choose from values in ErrorLv Class.')