import sys, os
import logging
import datetime

module_name = 'Streetview_Module'
debug_mode = True

class LoggingWrapper(object):

    def __init__(self, log_folder_path=None):
        self.debug_mode = debug_mode

        # Create logger with module name
        logger = logging.getLogger(module_name)
        logger.setLevel(logging.DEBUG)

        # create file handler which logs even debug messages
        now = datetime.datetime.now()
        log_file = '{}{}{}{}{}{}.log'.format(now.year, now.month, now.day,
                                                  now.hour, now.minute,
                                                  now.second)
        # If no folder provided, output to stderr
        if log_folder_path == None:
            fh = logging.StreamHandler(sys.stderr)
        else:
            log_file = os.path.join(log_folder_path, log_file)
            fh = logging.FileHandler(log_file)

        fh.setLevel(logging.DEBUG)

        # create console handler with a higher log level
        ch = logging.StreamHandler()
        ch.setLevel(logging.ERROR)

        # create formatter and add it to the handlers
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        fh.setFormatter(formatter)
        ch.setFormatter(formatter)

        # add the handlers to the logger
        logger.addHandler(fh)
        logger.addHandler(ch)

[((14, 17, 14, 47), 'logging.getLogger', 'logging.getLogger', ({(14, 35, 14, 46): 'module_name'}, {}), '(module_name)', False, 'import logging\n'), ((18, 14, 18, 37), 'datetime.datetime.now', 'datetime.datetime.now', ({}, {}), '()', False, 'import datetime\n'), ((32, 13, 32, 36), 'logging.StreamHandler', 'logging.StreamHandler', ({}, {}), '()', False, 'import logging\n'), ((36, 20, 36, 93), 'logging.Formatter', 'logging.Formatter', ({(36, 38, 36, 92): '"""%(asctime)s - %(name)s - %(levelname)s - %(message)s"""'}, {}), "('%(asctime)s - %(name)s - %(levelname)s - %(message)s')", False, 'import logging\n'), ((24, 17, 24, 50), 'logging.StreamHandler', 'logging.StreamHandler', ({(24, 39, 24, 49): 'sys.stderr'}, {}), '(sys.stderr)', False, 'import logging\n'), ((26, 23, 26, 62), 'os.path.join', 'os.path.join', ({(26, 36, 26, 51): 'log_folder_path', (26, 53, 26, 61): 'log_file'}, {}), '(log_folder_path, log_file)', False, 'import sys, os\n'), ((27, 17, 27, 46), 'logging.FileHandler', 'logging.FileHandler', ({(27, 37, 27, 45): 'log_file'}, {}), '(log_file)', False, 'import logging\n')]