Commit dde8f83a authored by c.fortmanngrote's avatar c.fortmanngrote
Browse files

Utilize app.logger everywhere.

parent eebfc57e
Pipeline #258999 failed with stages
in 4 minutes and 19 seconds
......@@ -24,14 +24,13 @@ app.config['UPLOAD_DIR'] = upload_dir
formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(module)s: %(message)s')
handler = logging.FileHandler(filename="/tmp/rarefan.log")
handler.setFormatter(formatter)
handler.setLevel(logging.DEBUG)
# Configure root logger (this config will trickle down to all module loggers.)
logging.basicConfig(handlers=[handler], level=logging.DEBUG)
logger = logging.getLogger(__name__)
app.logger.addHandler(handler)
if app.debug:
logger.debug("****************** Debug mode is active ******************")
app.logger.debug("****************** Debug mode is active ******************")
# csrf = CSRFProtect()
......
......@@ -4,9 +4,9 @@ from app.models import Job as DBJob
from app.utilities.checkers import parse_results
from app.tasks.email import email_task
from app.tasks.zip import zip_task
from app import app
import logging
logger = logging.getLogger('rarefan')
logger = app.logger
def rarefan_on_success(job, result):
""" Callback for the 'rarefan' task if completed successfully. """
......
......@@ -5,11 +5,8 @@ import os
import sys
import rq
from rq.exceptions import NoSuchJobError
import logging
logger = logging.getLogger(__name__)
from app import app, db
logger = app.logger
class Job(db.Document):
......
......@@ -34,7 +34,7 @@ import subprocess
import tempfile
import time
logger = logging.getLogger(__name__)
logger = app.logger
def get_status_code(run_id_path):
# Check if the run has finished.
......@@ -520,7 +520,9 @@ def test_task():
@app.route('/test_mail')
def test_mail():
logger.debug("Attempting to send mail throug redis queue.")
job = app.queue.enqueue(email_test)
logger.debug(job)
time.sleep(3)
......
......@@ -19,14 +19,15 @@ from app.views import AnalysisForm
from app.models import Job as DBJob
import jinja2
import logging
logger = logging.getLogger(__name__)
app.app_context().push()
logger = app.logger
def email_test():
recipients = ['grotec@evolbio.mpg.de']
logger.debug("Attempting to send email to %s", recipients[0])
message = Message("Test from flask",
sender="rarefan@evolbio.mpg.de",
......@@ -39,7 +40,7 @@ def email_test():
logger.debug("Mail was sent: %s", str(success))
logger.debug("Mail message was: %s", str(message))
return success, message
return success, str(message)
def email_task(run_id):
......@@ -99,3 +100,6 @@ def email_task(run_id):
dbjob.save()
logger.debug("Mail sent? %s", str(is_sent))
if __name__ == "__main__":
email_test()
......@@ -7,8 +7,10 @@ import subprocess
from app.models import Job as DBJob
from rq import get_current_job
import logging
logger = logging.getLogger(__name__)
from app import app
app.app_context().push()
logger = app.logger
from app.utilities.rarefan_cli import rarefan_command
......
# usage: $> rq enqueue -p app.tasks.redis_tests example 10
import time
import logging
logger = logging.getLogger(__name__)
from app import app
app.app_context().push()
logger = app.logger
def example(seconds):
seconds=int(seconds)
......
......@@ -5,9 +5,9 @@ import shlex
import shutil
from app.models import Job as DBJob
from rq import get_current_job
import logging
logger = logging.getLogger(__name__)
from app import app
app.app_context().push()
logger = app.logger
def tree_task(run_dir, treefile=None):
""" Generate a phylogenetic tree from all DNA sequence files in given directory.
......
......@@ -6,8 +6,9 @@ import shutil
from app.models import Job as DBJob
from rq import get_current_job
import logging
logger = logging.getLogger(__name__)
from app import app
app.app_context().push()
logger = app.logger
def zip_task(run_dir):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment