mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 19:04:18 +00:00
27 lines
844 B
Python
27 lines
844 B
Python
import os
|
|
import logging
|
|
|
|
|
|
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
|
|
|
|
|
|
if __name__ == '__main__':
|
|
init_logger()
|