mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Add different logging levels.
This commit is contained in:
parent
682ca30991
commit
2991082f1f
@ -40,13 +40,15 @@ class DevelopmentConfig(Config):
|
|||||||
file_path = os.path.join(os.getcwd(), 'logs/opaque_web.log')
|
file_path = os.path.join(os.getcwd(), 'logs/opaque_web.log')
|
||||||
log = open(file_path, 'w+')
|
log = open(file_path, 'w+')
|
||||||
log.close()
|
log.close()
|
||||||
|
if os.environ.get('FLASK_CONFIG') == 'development':
|
||||||
log_format = ("%(asctime)s - %(levelname)s - %(name)s - "
|
log_format = ("%(asctime)s - %(levelname)s - %(name)s - "
|
||||||
"%(filename)s - %(lineno)d - %(message)s")
|
"%(filename)s - %(lineno)d - %(message)s")
|
||||||
logging.basicConfig(filename='logs/opaque_web.log', level='WARNING',
|
logging.basicConfig(filename='logs/opaque_web.log', level='WARNING',
|
||||||
format=log_format, datefmt='%Y-%m-%d %H:%M:%S',
|
format=log_format, datefmt='%Y-%m-%d %H:%M:%S',
|
||||||
filemode='w')
|
filemode='w')
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.warning('Logging has started with level WARNING.')
|
logger.warning('Logging has started with level WARNING.'
|
||||||
|
' From development config.')
|
||||||
|
|
||||||
|
|
||||||
class TestingConfig(Config):
|
class TestingConfig(Config):
|
||||||
@ -71,13 +73,15 @@ class ProductionConfig(Config):
|
|||||||
file_path = os.path.join(os.getcwd(), 'logs/opaque_web.log')
|
file_path = os.path.join(os.getcwd(), 'logs/opaque_web.log')
|
||||||
log = open(file_path, 'w+')
|
log = open(file_path, 'w+')
|
||||||
log.close()
|
log.close()
|
||||||
|
if os.environ.get('FLASK_CONFIG') == 'production':
|
||||||
log_format = ("%(asctime)s - %(levelname)s - %(name)s - "
|
log_format = ("%(asctime)s - %(levelname)s - %(name)s - "
|
||||||
"%(filename)s - %(lineno)d - %(message)s")
|
"%(filename)s - %(lineno)d - %(message)s")
|
||||||
logging.basicConfig(filename='logs/opaque_web.log', level='ERROR',
|
logging.basicConfig(filename='logs/opaque_web.log', level='ERROR',
|
||||||
format=log_format, datefmt='%Y-%m-%d %H:%M:%S',
|
format=log_format, datefmt='%Y-%m-%d %H:%M:%S',
|
||||||
filemode='w')
|
filemode='w')
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.error('Logging has started with level ERROR.')
|
logger.error('Logging has started with level ERROR.'
|
||||||
|
' From production config.')
|
||||||
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
Loading…
Reference in New Issue
Block a user