From f6959d67bd4af2eb03c7ee40d5699766eeabb21a Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 20 Jun 2025 07:54:39 -0700 Subject: [PATCH 1/2] add debug option for extra logs --- viewer/app.py | 11 +++++++++++ viewer/functions/commandline.py | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/viewer/app.py b/viewer/app.py index e4bdd8c6f..58866582d 100755 --- a/viewer/app.py +++ b/viewer/app.py @@ -4,6 +4,7 @@ from gevent import monkey monkey.patch_all() +import http.client # noqa: E402 import logging # noqa: E402 import ssl # noqa: E402 import threading # noqa: E402 @@ -65,6 +66,16 @@ logger = logging.getLogger("localdb") # ============================== # setupLogging("logs/development.log") +if args.debug: + logger.setLevel(logging.DEBUG) + http.client.HTTPConnection.debuglevel = 1 + # initialize logging here to see dbeug output from requests + logging.basicConfig() + logging.getLogger().setLevel(logging.DEBUG) + requests_log = logging.getLogger("requests.packages.urllib3") + requests_log.setLevel(logging.DEBUG) + requests_log.propagate = True + app_kwargs = {"host": "0.0.0.0", "port": args.fport, "debug": False} # ============================== # Setup SSL Certificate diff --git a/viewer/functions/commandline.py b/viewer/functions/commandline.py index b2f77b647..de2820fa7 100755 --- a/viewer/functions/commandline.py +++ b/viewer/functions/commandline.py @@ -91,6 +91,11 @@ def getArgs(): help="Disable live notifications", action="store_true", ) + parser.add_argument( + "--debug", + help="Enable debug mode (warning: lots of logging)", + action="store_true", + ) args, unknown_args = parser.parse_known_args() @@ -174,6 +179,8 @@ def getArgs(): args.secret_key = conf["flask"]["secret_key"] if "notifications" in conf["flask"] and not args.disable_notifications: args.disable_notifications = conf["flask"]["notifications"] + if "debug" in conf["flask"] and not args.debug: + args.debug = conf["flask"]["debug"] if "userDB" in conf and "db" in conf.get("userDB", {}) and not args.userdb: args.userdb = conf["userDB"]["db"] @@ -207,5 +214,7 @@ def getArgs(): args.secret_key = os.urandom(24) if not args.disable_notifications: args.disable_notifications = False + if not args.debug: + args.debug = False return args -- GitLab From 85a936df33aa853b585a6ae1caafadb5f24bd7cd Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Tue, 24 Jun 2025 07:37:53 -0700 Subject: [PATCH 2/2] pycurl debug --- viewer/app.py | 11 +++++++++++ viewer/functions/common.py | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/viewer/app.py b/viewer/app.py index 58866582d..72a98f314 100755 --- a/viewer/app.py +++ b/viewer/app.py @@ -12,6 +12,7 @@ import uuid # noqa: E402 import arrow # noqa: E402 import itksn # noqa: E402 +import pycurl # noqa: E402 import pytz # noqa: E402 from flask import ( # noqa: E402 Flask, @@ -66,7 +67,17 @@ logger = logging.getLogger("localdb") # ============================== # setupLogging("logs/development.log") + +class VerboseCurl(pycurl.Curl): + def __init__(self): + super().__init__() + self.setopt(pycurl.VERBOSE, True) + + if args.debug: + # monkeypatch to get verbose curl + pycurl.Curl = VerboseCurl + logger.setLevel(logging.DEBUG) http.client.HTTPConnection.debuglevel = 1 # initialize logging here to see dbeug output from requests diff --git a/viewer/functions/common.py b/viewer/functions/common.py index cde49a931..721b4bef1 100755 --- a/viewer/functions/common.py +++ b/viewer/functions/common.py @@ -107,8 +107,9 @@ if args.logfile: handler_file.setFormatter(formatter_file) logger.addHandler(handler_file) -logging.getLogger("matplotlib").setLevel(logging.ERROR) logging.getLogger("itkdb").setLevel(logging.ERROR) +logging.getLogger("matplotlib").setLevel(logging.ERROR) +logging.getLogger("pymongo").setLevel(logging.ERROR) ##################### -- GitLab