LoggingConfiguration._get_dict_config()   B
last analyzed

Complexity

Conditions 1

Size

Total Lines 39

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 39
ccs 2
cts 2
cp 1
crap 1
rs 8.8571
1
"""Module which contains logging configuration."""
2
# pylint: disable=line-too-long
0 ignored issues
show
introduced by
Locally disabling line-too-long (C0301)
Loading history...
3 1
import logging.config
4
5 1
LOG = logging.getLogger(__name__)
6
7
8 1
class LoggingConfiguration:
9
    """Contains configuration for logging."""
10
11 1
    @staticmethod
12
    def init():
13
        """
14
        Initialize logging.
15
        """
16 1
        logging.config.dictConfig(LoggingConfiguration._get_dict_config())
17 1
        LOG.debug('Logger configured successfully!')
18
19 1
    @classmethod
20
    def _get_dict_config(cls):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
21 1
        return {
22
            'version': 1,
23
            'disable_existing_loggers': False,
24
            'formatters': {
25
                'standard': {
26
                    'format': '%(asctime)s [%(levelname)s] %(name)s %(lineno)d: %(message)s'
27
                },
28
            },
29
            'handlers': {
30
                'default': {
31
                    'level': 'INFO',
32
                    'formatter': 'standard',
33
                    'class': 'logging.StreamHandler',
34
                },
35
                'file': {
36
                    'level': 'DEBUG',
37
                    'formatter': 'standard',
38
                    'class': 'logging.handlers.RotatingFileHandler',
39
                    'filename': 'grortir.log'
40
                },
41
                'file_result': {
42
                    'level': 'INFO',
43
                    'formatter': 'standard',
44
                    'class': 'logging.handlers.RotatingFileHandler',
45
                    'filename': 'grortir-results.log'
46
                }
47
            },
48
            'loggers': {
49
                '': {
50
                    'handlers': ['default', 'file'],
51
                    'level': 'DEBUG',
52
                    'propagate': True
53
                },
54
                'results_logger': {
55
                    'handlers': ['file_result'],
56
                    'level': 'DEBUG',
57
                    'propagate': True
58
                }
59
            }
60
        }
61