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)

[((273, 303), 'logging.getLogger', 'logging.getLogger', (['module_name'], {}), '(module_name)\n', (290, 303), False, 'import logging\n'), ((419, 442), 'datetime.datetime.now', 'datetime.datetime.now', ([], {}), '()\n', (440, 442), False, 'import datetime\n'), ((1020, 1043), 'logging.StreamHandler', 'logging.StreamHandler', ([], {}), '()\n', (1041, 1043), False, 'import logging\n'), ((1154, 1227), 'logging.Formatter', 'logging.Formatter', (['"""%(asctime)s - %(name)s - %(levelname)s - %(message)s"""'], {}), "('%(asctime)s - %(name)s - %(levelname)s - %(message)s')\n", (1171, 1227), False, 'import logging\n'), ((755, 788), 'logging.StreamHandler', 'logging.StreamHandler', (['sys.stderr'], {}), '(sys.stderr)\n', (776, 788), False, 'import logging\n'), ((826, 865), 'os.path.join', 'os.path.join', (['log_folder_path', 'log_file'], {}), '(log_folder_path, log_file)\n', (838, 865), False, 'import sys, os\n'), ((883, 912), 'logging.FileHandler', 'logging.FileHandler', (['log_file'], {}), '(log_file)\n', (902, 912), False, 'import logging\n')]