diff options
-rw-r--r-- | crocoite/logger.py | 2 | ||||
-rw-r--r-- | crocoite/test_logger.py | 26 |
2 files changed, 25 insertions, 3 deletions
diff --git a/crocoite/logger.py b/crocoite/logger.py index 1a269b1..e69df5e 100644 --- a/crocoite/logger.py +++ b/crocoite/logger.py @@ -85,7 +85,7 @@ class Logger: self.consumer.remove (consumer) class Consumer: - def __call__ (self, level, *args, **kwargs): + def __call__ (self, level, *args, **kwargs): # pragma: no cover raise NotImplementedError () class NullConsumer (Consumer): diff --git a/crocoite/test_logger.py b/crocoite/test_logger.py index 8a34aab..3af1321 100644 --- a/crocoite/test_logger.py +++ b/crocoite/test_logger.py @@ -1,9 +1,9 @@ import pytest -from .logger import Logger, Consumer, NullConsumer +from .logger import Logger, Consumer, NullConsumer, Level, DatetimeConsumer @pytest.fixture def logger (): - return Logger (consumer=[NullConsumer ()]) + return Logger (consumer=[NullConsumer (), DatetimeConsumer ()]) class QueueConsumer (Consumer): def __init__ (self): @@ -58,3 +58,25 @@ def test_consumer (logger): assert ret['foo'] == 'bar' assert ret['inherit'] == 1 +def test_multiarg (logger): + # single argument + ret = logger.debug('maybe', foo='bar') + assert ret['msg'] == 'maybe' + assert ret['foo'] == 'bar' + + # multi arguments + ret = logger.debug('may', 'be', foo='bar') + assert ret['msg'] == ('may', 'be') + assert ret['foo'] == 'bar' + +def test_call (logger): + for level in ('debug', Level.DEBUG): + ret = logger(level, 'arg1', 'arg2', foo='bar') + assert ret['level'] == Level.DEBUG + assert ret['msg'] == ('arg1', 'arg2') + assert ret['foo'] == 'bar' + +def test_datetime (logger): + ret = logger.debug() + assert 'date' in ret + |