summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Albrecht <palbrecht@mailbox.org>2023-07-21 14:20:26 +0200
committerPhilipp Albrecht <palbrecht@mailbox.org>2023-07-21 14:23:15 +0200
commit01ab247a410488f86ac57cf07e22cca5e62bc92c (patch)
treec10b53a21a316dee9d2b42af3ea737df29df2339
parent5da4c6022ec424bfb37292fabe10fc8100f65b1b (diff)
downloadqutebrowser-01ab247a410488f86ac57cf07e22cca5e62bc92c.tar.gz
qutebrowser-01ab247a410488f86ac57cf07e22cca5e62bc92c.zip
Initialize logging as early as possible
Now that `qutebrowser.utils.log` is a Qt-free zone, we can initialize logging before `machinery.init()` without crashing.
-rw-r--r--qutebrowser/misc/earlyinit.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py
index 72cc7b3f5..57e821784 100644
--- a/qutebrowser/misc/earlyinit.py
+++ b/qutebrowser/misc/earlyinit.py
@@ -295,12 +295,22 @@ def init_log(args):
Args:
args: The argparse namespace.
"""
- from qutebrowser.utils import log, qtlog
+ from qutebrowser.utils import log
log.init_log(args)
- qtlog.init(args)
log.init.debug("Log initialized.")
+def init_qtlog(args):
+ """Initialize Qt logging.
+
+ Args:
+ args: The argparse namespace.
+ """
+ from qutebrowser.utils import log, qtlog
+ qtlog.init(args)
+ log.init.debug("Qt log initialized.")
+
+
def check_optimize_flag():
"""Check whether qutebrowser is running with -OO."""
from qutebrowser.utils import log
@@ -333,16 +343,18 @@ def early_init(args):
Args:
args: The argparse namespace.
"""
+ # Init logging as early as possible
+ init_log(args)
# First we initialize the faulthandler as early as possible, so we
# theoretically could catch segfaults occurring later during earlyinit.
init_faulthandler()
# Then we configure the selected Qt wrapper
info = machinery.init(args)
+ # Init Qt logging after machinery is initialized
+ init_qtlog(args)
# Here we check if QtCore is available, and if not, print a message to the
# console or via Tk.
check_qt_available(info)
- # Init logging as early as possible
- init_log(args)
# Now we can be sure QtCore is available, so we can print dialogs on
# errors, so people only using the GUI notice them as well.
check_libraries()