mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
26 lines
843 B
Python
26 lines
843 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() |