Exemple #1
0
 def test_it_converts_str_level_into_an_integer(self):
     self.assertEqual(check_level("CRITICAL"), 50)
     self.assertEqual(check_level("FATAL"), 50)
     self.assertEqual(check_level("ERROR"), 40)
     self.assertEqual(check_level("WARNING"), 30)
     self.assertEqual(check_level("WARN"), 30)
     self.assertEqual(check_level("INFO"), 20)
     self.assertEqual(check_level("DEBUG"), 10)
     self.assertEqual(check_level("NOTSET"), 0)
Exemple #2
0
 def __init__(self, level: LogLevel = LogLevel.NOTSET) -> None:
     """
     Initializes the instance - basically setting the formatter to None
     and the filter list to empty.
     """
     Filterer.__init__(self)
     self._level = check_level(level)
     self.formatter: Formatter = _default_formatter
Exemple #3
0
    def __init__(self, *, name="aiologger", level=LogLevel.NOTSET) -> None:
        super(Logger, self).__init__()
        self.name = name
        self.level = check_level(level)
        self.parent = None
        self.propagate = True
        self.handlers: List[Handler] = []
        self.disabled = False
        self._was_shutdown = False

        self._dummy_task: Optional[Task] = None
Exemple #4
0
 def __init__(
     self,
     level: LogLevel = LogLevel.NOTSET,
     *,
     loop: Optional[AbstractEventLoop] = None,
 ) -> None:
     """
     Initializes the instance - basically setting the formatter to None
     and the filter list to empty.
     """
     Filterer.__init__(self)
     self._level = check_level(level)
     self.formatter: Optional[Formatter] = None
     self._loop: Optional[asyncio.AbstractEventLoop] = loop
Exemple #5
0
    def __init__(
        self, *, name="aiologger", level=LogLevel.NOTSET, loop=None
    ) -> None:
        super(Logger, self).__init__()
        self.name = name
        self.level = check_level(level)
        self.parent = None
        self.propagate = True
        self.handlers = []
        self.disabled = False
        self._loop = loop
        self._was_shutdown = False

        self._dummy_task = None
Exemple #6
0
 def level(self, value: Union[str, int, LogLevel]):
     """
     Set the logging level of this handler.
     """
     self._level = check_level(value)
Exemple #7
0
 def test_it_raises_a_ValueError_if_level_is_unknown(self):
     for unknown_level in ["PERIGO", "XABLAU", 42]:
         with self.assertRaises(ValueError):
             check_level(unknown_level)
Exemple #8
0
 def test_it_returns_level_as_is_if_level_is_a_valid_integer_level(self):
     self.assertEqual(check_level(50), 50)
Exemple #9
0
 def test_it_raises_a_TypeError_if_level_has_an_invalid_type(self):
     for invalid_level in [None, {}, [], b"warn"]:
         with self.assertRaises(TypeError):
             check_level(invalid_level)