mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
31 lines
984 B
Python
31 lines
984 B
Python
import os
|
|
import logging
|
|
|
|
|
|
def init_logger():
|
|
'''
|
|
Functions initiates a logger instance.
|
|
'''
|
|
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__':
|
|
init_logger()
|