tracim.lib.utils.logger.Logger.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
Coding Style introduced by
This module 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...
2
import logging
3
4
5
class Logger(object):
0 ignored issues
show
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
6
    """
7
    Global logger
8
    """
9
    TPL = '[{cls}] {msg}'
10
11
    def __init__(self, logger_name):
12
        self._name = logger_name
13
        self._logger = logging.getLogger(self._name)
14
15
    @classmethod
16
    def _txt(cls, instance_or_class):
17
        if instance_or_class.__class__.__name__ in ('function', 'type'):
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
18
            return instance_or_class.__name__
19
        else:
20
            return instance_or_class.__class__.__name__
21
22
    def debug(self, instance_or_class, message):
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...
23
        self._logger.debug(
24
            Logger.TPL.format(cls=self._txt(instance_or_class), msg=message)
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
25
        )
26
27
    def error(self, instance_or_class, message, exc_info=0):
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...
28
        self._logger.error(
29
            Logger.TPL.format(
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
30
                cls=self._txt(instance_or_class),
31
                msg=message,
32
                exc_info=exc_info
33
            )
34
        )
35
36
    def info(self, instance_or_class, message):
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...
37
        self._logger.info(
38
            Logger.TPL.format(cls=self._txt(instance_or_class), msg=message)
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
39
        )
40
41
    def warning(self, instance_or_class, message):
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...
42
        self._logger.warning(
43
            Logger.TPL.format(cls=self._txt(instance_or_class), msg=message)
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
44
        )
45
46
47
logger = Logger('tracim')
0 ignored issues
show
Coding Style Naming introduced by
The name logger does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
48