import logging


class Logger(object):
    """Logger class."""

    # Default logging level
    __default_logging_level = logging.INFO

    # "logging" object
    __l = None

    def __init__(self, name: str):
        """Initialize logger object for a given name."""
        # noinspection SpellCheckingInspection

        self.__l = logging.getLogger(name)
        if not self.__l.handlers:
            formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(module)s - %(message)s')

            handler = logging.StreamHandler()
            handler.setFormatter(formatter)

            self.__l.setLevel(self.__default_logging_level)
            self.__l.addHandler(handler)

            # Don't propagate handler to root logger
            # (http://stackoverflow.com/a/21127526/200603)
            self.__l.propagate = False

    def error(self, message: str) -> None:
        """Log error message."""
        self.__l.error(message)

    def warning(self, message: str) -> None:
        """Log warning message."""
        self.__l.warning(message)

    def info(self, message: str) -> None:
        """Log informational message."""
        self.__l.info(message)

    def debug(self, message: str) -> None:
        """Log debugging message."""
        self.__l.debug(message)


def create_logger(name: str) -> Logger:
    """Create and return Logger object."""
    return Logger(name=name)

@@ -8,16 +8,26 @@
 logging%0A
+import os%0A
 %0A%0Aclass 
@@ -66,26 +66,200 @@
 ass.
-%22%22%22%0A%0A    # Default
+%0A    %0A    Supports setting custom logging level with an environment variable, e.g.:%0A    %0A    MC_LOGGING_LEVEL=DEBUG python3 script.py    %0A    %22%22%22%0A%0A    # Environment variable to read the custom
  log
@@ -272,22 +272,134 @@
 evel
+ from
 %0A    __
-default
+logging_level_env_variable = 'MC_LOGGING_LEVEL'%0A%0A    # Valid logging levels and their %22logging%22 counterparts%0A    _
 _log
@@ -412,23 +412,297 @@
 evel
+s
  = 
-logging.INFO
+%7B%0A        'CRITICAL': logging.CRITICAL,%0A        'ERROR': logging.ERROR,%0A        'WARNING': logging.WARNING,%0A        'INFO': logging.INFO,%0A        'DEBUG': logging.DEBUG,%0A    %7D%0A%0A    # Default logging level (used when environment variable is not set)%0A    __default_logging_level = 'INFO'
 %0A%0A  
@@ -1146,25 +1146,24 @@
 (formatter)%0A
-%0A
             
@@ -1175,86 +1175,499 @@
 __l.
-setLevel(self.__default_logging_level)%0A            self.__l.addHandler(handler
+addHandler(handler)%0A%0A            logging_level = os.environ.get(self.__logging_level_env_variable, self.__default_logging_level)%0A            if logging_level not in self.__logging_levels:%0A                self.warning(%22Logging level '%25s' is invalid, resetting to default '%25s'%22 %25 (%0A                    logging_level, self.__default_logging_level%0A                ))%0A                logging_level = self.__default_logging_level%0A%0A            self.__l.setLevel(self.__logging_levels%5Blogging_level%5D
 )%0A%0A 

Make Logger class read logging level from “MC_LOGGING_LEVEL” env. variable