コード例 #1
0
ファイル: log.py プロジェクト: jjcorreao/tako
def set_log_level(level):
    """Set the level of logging for the user-generated logs.

    After this call, all messages at a numerically higher level
    (e.g. DEBUG if level is INFO) will be skipped.

    :param level: One of the constants defined in this module:
        NONE, FATAL, ERROR, WARN[ING], INFO, DEBUG, TRACE
    :type level: int
    :return: None
    :raise: ValueError if `level` is out of range or not an integer


    """
    if _ulog is None:
        return
    if isinstance(level, str):
        level = Level.to_number(level)
    if not isinstance(level, int) or not Level.NONE <= level <= Level.MAX:
        raise ValueError("level {} out of range {:d} .. {:d}".
                         format(level, Level.NONE, Level.MAX))
    _ulog.set_level(level)
コード例 #2
0
ファイル: kvp.py プロジェクト: jjcorreao/tako
    def from_dict(self, rec):
        """Add values from dict

        Convert timestamp to a number of seconds since the epoch (1-1-1970)
        Convert the level name to a number.
        """
        if Keyword.TIME in rec:
            ts = rec[Keyword.TIME]
            if isinstance(ts, str):
                self._time_string = ts
                # defer parsing of time until it is accessed
                self._str_time = True
            else:
                self._time_string = None
                self._str_time = False
        else:
            self._time_string = '1970-01-01T00:00:00'
            self._fields[Keyword.TIME] = 0
            self._str_time = False
        if Keyword.LEVEL in rec:
            lvl = rec[Keyword.LEVEL]
            if isinstance(lvl, str):
                rec[Keyword.LEVEL] = Level.to_number(lvl)
        self._fields.update(rec)