canonical-ubuntu-qa team mailing list archive
-
canonical-ubuntu-qa team
-
Mailing list archive
-
Message #00875
[Merge] ~andersson123/autopkgtest-cloud:fix_logging into autopkgtest-cloud:master
Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:fix_logging into autopkgtest-cloud:master.
Commit message:
DRAFT
Requested reviews:
Canonical's Ubuntu QA (canonical-ubuntu-qa)
For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/446056
DRAFT
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:fix_logging into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/request/app.py b/charms/focal/autopkgtest-web/webcontrol/request/app.py
index 8654ec2..9627ac2 100644
--- a/charms/focal/autopkgtest-web/webcontrol/request/app.py
+++ b/charms/focal/autopkgtest-web/webcontrol/request/app.py
@@ -67,7 +67,7 @@ def check_github_sig(request):
keymap = json.load(f)
key = keymap[package].encode("ASCII")
except (IOError, ValueError, KeyError, UnicodeEncodeError) as e:
- logging.error(
+ app.logger.error(
"Failed to load GitHub key for package %s: %s", package, e
)
return False
@@ -76,7 +76,7 @@ def check_github_sig(request):
payload_sha1 = "sha1=" + hmac.new(key, request.data, "sha1").hexdigest()
if hmac.compare_digest(sig_sha1, payload_sha1):
return True
- logging.error(
+ app.logger.error(
"check_github_sig: signature mismatch! received: %s calculated: %s",
sig_sha1,
payload_sha1,
@@ -93,7 +93,7 @@ def invalid(message, code=400):
html += "<p>You submitted an invalid request: %s</p>" % maybe_escape(
str(message)
)
- logging.error("Request failed with %i: %s", code, message)
+ app.logger.error("Request failed with %i: %s", code, message)
return HTML.format(html), code
@@ -105,12 +105,24 @@ def maybe_escape(value):
# Initialize app
PATH = os.path.join(os.path.sep, "run", "autopkgtest_webcontrol")
os.makedirs(PATH, exist_ok=True)
+###############################
+# logging.basicConfig(filename='/tmp/webcontrol.log', level=logging.INFO)
+FORMAT = "%(asctime)s : %(levelname)s : %(name)s : %(message)s"
+file_handler = logging.FileHandler("/tmp/webcontrol.log")
+file_handler.setFormatter(logging.Formatter(FORMAT))
+file_handler.setLevel(logging.INFO)
+###############################
app = Flask("request")
+###############################
+app.logger.addHandler(file_handler)
+app.logger.info("test logger please work oh my godim losingmy midn")
+###############################
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1)
# keep secret persistent between CGI invocations
secret_path = os.path.join(PATH, "secret_key")
setup_key(app, secret_path)
oid = OpenID(app, os.path.join(PATH, "openid"), safe_roots=[])
+app.logger.info("Hello help me")
#
@@ -287,6 +299,6 @@ def identify(resp):
@app.route("/logout")
def logout():
- """Clear user session, logging them out."""
+ """Clear user session, app.logger them out."""
session.clear()
return redirect(oid.get_next_url())
Follow ups