mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-13 09:30:40 +00:00
integrate nopaque repo
This commit is contained in:
0
daemon/logger/__init__.py
Normal file
0
daemon/logger/__init__.py
Normal file
26
daemon/logger/logger.py
Normal file
26
daemon/logger/logger.py
Normal file
@ -0,0 +1,26 @@
|
||||
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()
|
Reference in New Issue
Block a user