Add simple logging

This commit is contained in:
Stephan Porada 2019-09-11 14:50:29 +02:00
parent 51d2623e2e
commit 230d057fee
3 changed files with 20 additions and 1 deletions

2
app/logs/main.log Normal file
View File

@ -0,0 +1,2 @@
2019-09-11 12:48:21 - WARNING - werkzeug - _internal.py - 122 - * Debugger is active!
2019-09-11 12:48:21 - INFO - werkzeug - _internal.py - 122 - * Debugger PIN: 140-241-697

View File

@ -4,8 +4,9 @@ from flask_login import current_user, login_required
from . import main
from .forms import CreateCorpusForm
from .. import db
from ..models import Corpus
from ..models import Corpus, Job
import os
import logging
@main.route('/')
@ -137,3 +138,13 @@ def job_download(job_id):
return send_from_directory(as_attachment=True,
directory=dir,
filename=file)
@main.route('/jobs/<int:job_id>/delete')
@login_required
def delete_job(job_id):
logger = logging.getLogger(__name__)
job = Job.query.filter_by(id=job_id).first()
job.flag_for_stop()
logger.warning('Job status: {}'.format(job.status))
return redirect(url_for('main.dashboard'))

View File

@ -1,4 +1,5 @@
import os
import logging
class Config:
@ -35,6 +36,11 @@ class DevelopmentConfig(Config):
os.environ.get('POSTGRES_PASSWORD'),
os.environ.get('POSTGRES_DB_NAME')
)
log_format = "%(asctime)s - %(levelname)s - %(name)s - "\
"%(filename)s - %(lineno)d - %(message)s"
logging.basicConfig(filename='app/logs/main.log', level='WARNING',
format=log_format, datefmt='%Y-%m-%d %H:%M:%S',
filemode='w')
class TestingConfig(Config):