[LNT] r255964 - Tweaks to logging system and messages all over the system
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 17 17:45:01 PST 2015
Author: cmatthews
Date: Thu Dec 17 19:45:00 2015
New Revision: 255964
URL: http://llvm.org/viewvc/llvm-project?rev=255964&view=rev
Log:
Tweaks to logging system and messages all over the system
Modified:
lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py
lnt/trunk/lnt/server/ui/app.py
lnt/trunk/lnt/server/ui/templates/log.html
lnt/trunk/lnt/server/ui/views.py
lnt/trunk/lnt/testing/util/commands.py
lnt/trunk/lnt/util/ImportData.py
lnt/trunk/lnt/util/async_ops.py
Modified: lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py?rev=255964&r1=255963&r2=255964&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py (original)
+++ lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py Thu Dec 17 19:45:00 2015
@@ -35,6 +35,7 @@ def regression_evolution(ts, run_id):
"""
note("Running regression evolution")
+ changed = 0
regressions = ts.query(ts.Regression).all()
detects = [r for r in regressions if r.state == RegressionState.DETECTED]
@@ -43,6 +44,7 @@ def regression_evolution(ts, run_id):
note("Detected fixed regression" + str(regression))
regression.state = RegressionState.IGNORED
regression.title = regression.title + " [Detected Fixed]"
+ changed += 1
ts.commit()
staged = [r for r in regressions if r.state == RegressionState.STAGED]
@@ -52,6 +54,7 @@ def regression_evolution(ts, run_id):
note("Staged fixed regression" + str(regression))
regression.state = RegressionState.DETECTED_FIXED
regression.title = regression.title + " [Detected Fixed]"
+ changed += 1
ts.commit()
active = [r for r in regressions if r.state == RegressionState.ACTIVE]
@@ -61,6 +64,8 @@ def regression_evolution(ts, run_id):
note("Active fixed regression" + str(regression))
regression.state = RegressionState.DETECTED_FIXED
regression.title = regression.title + " [Detected Fixed]"
+ changed += 1
ts.commit()
+ note("Changed the state of {} regressions".format(changed))
post_submission_hook = regression_evolution
Modified: lnt/trunk/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/app.py?rev=255964&r1=255963&r2=255964&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/app.py (original)
+++ lnt/trunk/lnt/server/ui/app.py Thu Dec 17 19:45:00 2015
@@ -20,7 +20,7 @@ import lnt.server.instance
import lnt.server.ui.filters
import lnt.server.ui.globals
import lnt.server.ui.views
-
+from lnt.testing.util.commands import warning
import lnt.server.ui.regression_views
from lnt.server.ui.api import load_api_resources
import lnt.server.db.rules_manager
@@ -89,6 +89,9 @@ class Request(flask.Request):
return self.testsuite
def close(self):
+ t = self.elapsed_time()
+ if t > 10:
+ warning("Request {} took {}s".format(self.url, t))
db = getattr(self, 'db', None)
if db is not None:
db.close()
@@ -138,9 +141,8 @@ class App(flask.Flask):
# Inject a fix for missing slashes on the root URL (see Flask issue
# #169).
self.wsgi_app = RootSlashPatchMiddleware(self.wsgi_app)
-
- self.lnt_logger = logging.getLogger('LNT')
- self.lnt_logger.setLevel(logging.DEBUG)
+ self.logger.setLevel(logging.DEBUG)
+
def load_config(self, instance):
self.instance = instance
@@ -163,14 +165,14 @@ class App(flask.Flask):
# Print to screen.
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
- self.lnt_logger.addHandler(ch)
+ self.logger.addHandler(ch)
# Log to mem for the /log view.
h = logging.handlers.MemoryHandler(1024 * 1024)
h.setLevel(logging.DEBUG)
- self.lnt_logger.addHandler(h)
self.logger.addHandler(h)
- self.old_config.mem_logger = h
+ # Also store the logger, so we can render the buffer in it.
+ self.config['mem_logger'] = h
if not self.debug:
LOG_FILENAME = "lnt.log"
@@ -182,7 +184,7 @@ class App(flask.Flask):
'[in %(pathname)s:%(lineno)d]'
))
rotating.setLevel(logging.DEBUG)
- self.lnt_logger.addHandler(rotating)
+ self.logger.addHandler(rotating)
except (OSError, IOError) as e:
print >> sys.stderr, "Error making log file", LOG_FILENAME, str(e)
print >> sys.stderr, "Will not log to file."
Modified: lnt/trunk/lnt/server/ui/templates/log.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/log.html?rev=255964&r1=255963&r2=255964&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/log.html (original)
+++ lnt/trunk/lnt/server/ui/templates/log.html Thu Dec 17 19:45:00 2015
@@ -17,7 +17,7 @@
</tr>
</thead>
<tbody class="searchable">
-{% for item in old_config.mem_logger.buffer %}
+{% for item in config.mem_logger.buffer[::-1] %}
{% if item.levelname|string() == 'WARNING' %}
<tr class="warning">
{% elif item.levelname|string() == 'ERROR' %}
Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=255964&r1=255963&r2=255964&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Thu Dec 17 19:45:00 2015
@@ -14,7 +14,8 @@ from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
-
+from flask import flash
+from lnt.testing.util.commands import warning, error, note
import sqlalchemy.sql
from sqlalchemy.orm.exc import NoResultFound
@@ -1171,4 +1172,5 @@ def rules():
@frontend.route('/log')
def log():
+ note("Showing log page.")
return render_template("log.html")
Modified: lnt/trunk/lnt/testing/util/commands.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/util/commands.py?rev=255964&r1=255963&r2=255964&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/util/commands.py (original)
+++ lnt/trunk/lnt/testing/util/commands.py Thu Dec 17 19:45:00 2015
@@ -7,11 +7,19 @@ import inspect
import os
import sys
import logging
+from flask import current_app
# FIXME: Find a better place for this code.
-note = lambda message: logging.getLogger('LNT').info(message)
-warning = lambda message: logging.getLogger('LNT').warning(message)
-error = lambda message: logging.getLogger('LNT').error(message)
+def getLogger():
+ try:
+ logger = current_app.logger
+ except RuntimeError:
+ print "Using other logger."
+ logger = logging.getLogger("LNT")
+ return logger
+note = lambda message: getLogger().info(message)
+warning = lambda message: getLogger().warning(message)
+error = lambda message: getLogger().error(message)
def fatal(message):
Modified: lnt/trunk/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/ImportData.py?rev=255964&r1=255963&r2=255964&view=diff
==============================================================================
--- lnt/trunk/lnt/util/ImportData.py (original)
+++ lnt/trunk/lnt/util/ImportData.py Thu Dec 17 19:45:00 2015
@@ -3,7 +3,7 @@ import collections
import lnt.testing
import lnt.formats
import lnt.server.reporting.analysis
-
+from lnt.testing.util.commands import note
from lnt.util import NTEmailReport
@@ -116,7 +116,7 @@ def import_and_report(config, db_name, d
result['result_url'] = "db_{}/v4/{}/{}".format(db_name, ts_name, run.id)
result['report_time'] = time.time() - importStartTime
result['total_time'] = time.time() - startTime
-
+ note("Successfully created {}".format(result['result_url']))
# If this database has a shadow import configured, import the run into that
# database as well.
if config and config.databases[db_name].shadow_import:
Modified: lnt/trunk/lnt/util/async_ops.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/async_ops.py?rev=255964&r1=255963&r2=255964&view=diff
==============================================================================
--- lnt/trunk/lnt/util/async_ops.py (original)
+++ lnt/trunk/lnt/util/async_ops.py Thu Dec 17 19:45:00 2015
@@ -57,26 +57,29 @@ def async_run_job(job, ts, func_args):
except TimeoutError:
pass
+
def async_wrapper(job, ts_args, func_args):
- """Setup test-suite in this subprocess and run something."""
+ """Setup test-suite in this subprocess and run something.
+
+ Because of multipocessing, capture excptions and log messages,
+ and return them.
+ """
try:
print >>sys.stderr,"Test"
h = logging.handlers.MemoryHandler(1024 * 1024)
h.setLevel(logging.DEBUG)
logging.getLogger('LNT').addHandler(h)
- note("Running async wrapper")
- note(str(job))
+ note("Running async wrapper: {}".format(job.__name__))
_v4db = lnt.server.db.v4db.V4DB(**ts_args['db'])
ts = _v4db.testsuite[ts_args['tsname']]
- note("Calculating field changes for ")
job(ts, **func_args)
- note("Done calculating field changes")
except:
# Put all exception text into an exception and raise that for our
# parent process.
return Exception("".join(traceback.format_exception(*sys.exc_info())))
return h.buffer
+
def async_job_finished(arg):
if isinstance(arg, Exception):
raise arg
More information about the llvm-commits
mailing list