mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	First RessourceList update
This commit is contained in:
		@@ -6,20 +6,24 @@ def init_logger():
 | 
			
		||||
    '''
 | 
			
		||||
    Functions initiates a logger instance.
 | 
			
		||||
    '''
 | 
			
		||||
    if not os.path.isfile('logs/nopaqued.log'):
 | 
			
		||||
        file_path = os.path.join(os.getcwd(), 'logs/nopaqued.log')
 | 
			
		||||
        log = open(file_path, 'w+')
 | 
			
		||||
        log.close()
 | 
			
		||||
    logging.basicConfig(datefmt='%Y-%m-%d %H:%M:%S',
 | 
			
		||||
                        filemode='w', filename='logs/nopaqued.log',
 | 
			
		||||
                        format='%(asctime)s - %(levelname)s - %(name)s - '
 | 
			
		||||
                                '%(filename)s - %(lineno)d - %(message)s')
 | 
			
		||||
    logger = logging.getLogger(__name__)
 | 
			
		||||
    if os.environ.get('FLASK_CONFIG') == 'development':
 | 
			
		||||
        logger.setLevel(logging.DEBUG)
 | 
			
		||||
    if os.environ.get('FLASK_CONFIG') == 'production':
 | 
			
		||||
        logger.setLevel(logging.WARNING)
 | 
			
		||||
    return logger
 | 
			
		||||
    os.makedirs('logs', exist_ok=True)
 | 
			
		||||
    logging.basicConfig(filename='logs/nopaqued.log',
 | 
			
		||||
                        format='[%(asctime)s] %(levelname)s in '
 | 
			
		||||
                               '%(pathname)s:%(lineno)d - %(message)s',
 | 
			
		||||
                        datefmt='%Y-%m-%d %H:%M:%S', filemode='w')
 | 
			
		||||
    NOPAQUE_LOG_LEVEL = os.environ.get('NOPAQUE_LOG_LEVEL')
 | 
			
		||||
    if NOPAQUE_LOG_LEVEL is None:
 | 
			
		||||
        FLASK_CONFIG = os.environ.get('FLASK_CONFIG')
 | 
			
		||||
        if FLASK_CONFIG == 'development':
 | 
			
		||||
            logging.basicConfig(level='DEBUG')
 | 
			
		||||
        elif FLASK_CONFIG == 'testing':
 | 
			
		||||
            # TODO: Set an appropriate log level
 | 
			
		||||
            pass
 | 
			
		||||
        elif FLASK_CONFIG == 'production':
 | 
			
		||||
            logging.basicConfig(level='ERROR')
 | 
			
		||||
    else:
 | 
			
		||||
        logging.basicConfig(level=NOPAQUE_LOG_LEVEL)
 | 
			
		||||
    return logging.getLogger(__name__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user