def create_logger(self, args={}):
        """
        Create and configure the program's logger object.

        Log levels:
        DEBUG - Log everything. Hidden unless --debug is used.
        INFO - information only
        ERROR - Critical error
        :param args: Object containing program's parsed command line arguments
        :return: None
        """
        # Set up logging
        logger = logging.getLogger("SmartFileSorter")
        logger.level = logging.INFO

        if '--debug' in args and args['--debug'] is True:
            logger.setLevel(logging.DEBUG)

        file_log_formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s',
                                               '%Y-%m-%d %H:%M:%S')
        console_log_formatter = logging.Formatter('%(message)s')

        # Log to stdout
        stdout_stream = logging.StreamHandler(stream=sys.stdout)
        stdout_stream.setFormatter(console_log_formatter)
        logger.addHandler(stdout_stream)

        # Log to file if the option is chosen
        if '--log' in args and args['--log'] is not None:
            logfile = open(args['--log'], 'w')
            logfile_stream = logging.StreamHandler(stream=logfile)
            logfile_stream.setFormatter(file_log_formatter)
            logger.addHandler(logfile_stream)

        if '--dry-run' in args and args['--dry-run'] is True:
            logger.info('Running with --dry-run parameter. Actions will not be performed.')
        self.logger = logger
def create_logger ( self , args = { } ) : logger = logging . getLogger ( "SmartFileSorter" ) logger . level = logging . INFO if '--debug' in args and args [ '--debug' ] is True : logger . setLevel ( logging . DEBUG ) file_log_formatter = logging . Formatter ( '%(asctime)s %(name)s %(levelname)s %(message)s' , '%Y-%m-%d %H:%M:%S' ) console_log_formatter = logging . Formatter ( '%(message)s' ) stdout_stream = logging . StreamHandler ( stream = sys . stdout ) stdout_stream . setFormatter ( console_log_formatter ) logger . addHandler ( stdout_stream ) if '--log' in args and args [ '--log' ] is not None : logfile = open ( args [ '--log' ] , 'w' ) logfile_stream = logging . StreamHandler ( stream = logfile ) logfile_stream . setFormatter ( file_log_formatter ) logger . addHandler ( logfile_stream ) if '--dry-run' in args and args [ '--dry-run' ] is True : logger . info ( 'Running with --dry-run parameter. Actions will not be performed.' ) self . logger = logger
Create and configure the program's logger object.

        Log levels:
        DEBUG - Log everything. Hidden unless --debug is used.
        INFO - information only
        ERROR - Critical error
        :param args: Object containing program's parsed command line arguments
        :return: None