Add topic-specific loggers
This commit is contained in:
parent
99bd53de89
commit
1e256699f8
@ -50,6 +50,7 @@ import qutebrowser.network.qutescheme as qutescheme
|
||||
import qutebrowser.config.websettings as websettings
|
||||
import qutebrowser.network.proxy as proxy
|
||||
import qutebrowser.browser.quickmarks as quickmarks
|
||||
import qutebrowser.utils.log as log
|
||||
from qutebrowser.network.networkmanager import NetworkManager
|
||||
from qutebrowser.config.config import ConfigManager
|
||||
from qutebrowser.keyinput.modeman import ModeManager
|
||||
@ -242,8 +243,8 @@ class QuteBrowser(QApplication):
|
||||
raise ValueError("Invalid log level: {}".format(loglevel))
|
||||
logging.basicConfig(
|
||||
level=numeric_level,
|
||||
format='%(asctime)s [%(levelname)s] '
|
||||
'[%(module)s:%(funcName)s:%(lineno)s] %(message)s',
|
||||
format='%(asctime)s [%(levelname)s] [%(name)s|'
|
||||
'%(module)s:%(funcName)s:%(lineno)s] %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S')
|
||||
|
||||
def _init_misc(self):
|
||||
@ -274,7 +275,7 @@ class QuteBrowser(QApplication):
|
||||
try:
|
||||
os.remove(logname)
|
||||
except PermissionError:
|
||||
logging.warn("Could not remove crash log!")
|
||||
log.init.warn("Could not remove crash log!")
|
||||
else:
|
||||
self._init_crashlogfile()
|
||||
self._crashdlg = FatalCrashDialog(data)
|
||||
@ -284,10 +285,10 @@ class QuteBrowser(QApplication):
|
||||
# This means another instance is probably still running and
|
||||
# didn't remove the file. As we can't write to the same file,
|
||||
# we just leave faulthandler as it is and log to stderr.
|
||||
logging.warn("Empty crash.log detected. This means either "
|
||||
"another instance is running (then ignore this "
|
||||
"warning) or the file is lying here because "
|
||||
"of some earlier crash (then delete it).")
|
||||
log.init.warn("Empty crash.log detected. This means either "
|
||||
"another instance is running (then ignore this "
|
||||
"warning) or the file is lying here because "
|
||||
"of some earlier crash (then delete it).")
|
||||
self._crashlogfile = None
|
||||
else:
|
||||
# There's no log file, so we can use this to display crashes to the
|
||||
@ -318,15 +319,15 @@ class QuteBrowser(QApplication):
|
||||
|
||||
for e in self._args.command:
|
||||
if e.startswith(':'):
|
||||
logging.debug("Startup cmd {}".format(e))
|
||||
log.init.debug("Startup cmd {}".format(e))
|
||||
self.commandmanager.run_safely_init(e.lstrip(':'))
|
||||
else:
|
||||
logging.debug("Startup URL {}".format(e))
|
||||
log.init.debug("Startup URL {}".format(e))
|
||||
self._opened_urls.append(e)
|
||||
self.mainwindow.tabs.tabopen(e)
|
||||
|
||||
if self.mainwindow.tabs.count() == 0:
|
||||
logging.debug("Opening startpage")
|
||||
log.init.debug("Opening startpage")
|
||||
for url in self.config.get('general', 'startpage'):
|
||||
self.mainwindow.tabs.tabopen(url)
|
||||
|
||||
@ -486,7 +487,7 @@ class QuteBrowser(QApplication):
|
||||
try:
|
||||
self.lastWindowClosed.disconnect(self.shutdown)
|
||||
except TypeError:
|
||||
logging.exception("Preventing shutdown failed.")
|
||||
log.destroy.exception("Preventing shutdown failed.")
|
||||
QApplication.closeAllWindows()
|
||||
self._crashdlg = ExceptionCrashDialog(pages, history, exc)
|
||||
ret = self._crashdlg.exec_()
|
||||
@ -506,10 +507,10 @@ class QuteBrowser(QApplication):
|
||||
The sender of the quit signal (string)
|
||||
"""
|
||||
self._quit_status[sender] = True
|
||||
logging.debug("maybe_quit called from {}, quit status {}".format(
|
||||
log.destroy.debug("maybe_quit called from {}, quit status {}".format(
|
||||
sender, self._quit_status))
|
||||
if all(self._quit_status.values()):
|
||||
logging.debug("maybe_quit quitting.")
|
||||
log.destroy.debug("maybe_quit quitting.")
|
||||
self.quit()
|
||||
|
||||
@cmdutils.register(instance='', nargs=0)
|
||||
@ -531,8 +532,8 @@ class QuteBrowser(QApplication):
|
||||
except ValueError:
|
||||
pass
|
||||
argv = [sys.executable] + argv + pages
|
||||
logging.debug("Running {} with args {}".format(sys.executable,
|
||||
argv))
|
||||
log.procs.debug("Running {} with args {}".format(sys.executable,
|
||||
argv))
|
||||
subprocess.Popen(argv)
|
||||
if shutdown:
|
||||
self.shutdown()
|
||||
@ -588,41 +589,41 @@ class QuteBrowser(QApplication):
|
||||
if self._shutting_down:
|
||||
return
|
||||
self._shutting_down = True
|
||||
logging.debug("Shutting down...")
|
||||
log.destroy.debug("Shutting down...")
|
||||
# Save config
|
||||
if self.config.get('general', 'auto-save-config'):
|
||||
try:
|
||||
self.config.save()
|
||||
except AttributeError:
|
||||
logging.exception("Could not save config.")
|
||||
log.destroy.exception("Could not save config.")
|
||||
# Save command history
|
||||
try:
|
||||
self.cmd_history.save()
|
||||
except AttributeError:
|
||||
logging.exception("Could not save command history.")
|
||||
log.destroy.exception("Could not save command history.")
|
||||
# Save window state
|
||||
try:
|
||||
self._save_geometry()
|
||||
self.stateconfig.save()
|
||||
except AttributeError:
|
||||
logging.exception("Could not save window geometry.")
|
||||
log.destroy.exception("Could not save window geometry.")
|
||||
# Save cookies
|
||||
try:
|
||||
self.cookiejar.save()
|
||||
except AttributeError:
|
||||
logging.exception("Could not save cookies.")
|
||||
log.destroy.exception("Could not save cookies.")
|
||||
# Save quickmarks
|
||||
try:
|
||||
quickmarks.save()
|
||||
except AttributeError:
|
||||
logging.exception("Could not save quickmarks.")
|
||||
log.destroy.exception("Could not save quickmarks.")
|
||||
# Shut down tabs
|
||||
try:
|
||||
self.mainwindow.tabs.shutdown_complete.connect(partial(
|
||||
self._maybe_quit, 'tabs'))
|
||||
self.mainwindow.tabs.shutdown()
|
||||
except AttributeError: # mainwindow or tabs could still be None
|
||||
logging.exception("No mainwindow/tabs to shut down.")
|
||||
log.destroy.exception("No mainwindow/tabs to shut down.")
|
||||
self._maybe_quit('tabs')
|
||||
# Shut down networkmanager
|
||||
try:
|
||||
@ -631,7 +632,7 @@ class QuteBrowser(QApplication):
|
||||
self._maybe_quit, 'networkmanager'))
|
||||
self.networkmanager.deleteLater()
|
||||
except AttributeError:
|
||||
logging.exception("No networkmanager to shut down.")
|
||||
log.destroy.exception("No networkmanager to shut down.")
|
||||
self._maybe_quit('networkmanager')
|
||||
if self._crashlogfile is not None:
|
||||
# Re-enable faulthandler to stdout, then remove crash log
|
||||
@ -652,5 +653,5 @@ class QuteBrowser(QApplication):
|
||||
|
||||
Gets called when all tabs finished shutting down after shutdown().
|
||||
"""
|
||||
logging.debug("Shutdown complete, quitting.")
|
||||
log.destroy.debug("Shutdown complete, quitting.")
|
||||
self.quit()
|
||||
|
@ -18,7 +18,6 @@
|
||||
"""The main tabbed browser widget."""
|
||||
|
||||
import os
|
||||
import logging
|
||||
import subprocess
|
||||
from functools import partial
|
||||
|
||||
@ -34,6 +33,7 @@ import qutebrowser.utils.url as urlutils
|
||||
import qutebrowser.utils.message as message
|
||||
import qutebrowser.utils.webelem as webelem
|
||||
import qutebrowser.browser.quickmarks as quickmarks
|
||||
import qutebrowser.utils.log as log
|
||||
from qutebrowser.utils.misc import check_overflow, shell_escape
|
||||
from qutebrowser.utils.editor import ExternalEditor
|
||||
from qutebrowser.commands.exceptions import CommandError
|
||||
@ -351,7 +351,7 @@ class CommandDispatcher(QObject):
|
||||
else:
|
||||
mode = QClipboard.Clipboard
|
||||
target = "clipboard"
|
||||
logging.debug("Yanking to {}: '{}'".format(target, url))
|
||||
log.misc.debug("Yanking to {}: '{}'".format(target, url))
|
||||
QApplication.clipboard().setText(url, mode)
|
||||
message.info("URL yanked to {}".format(target))
|
||||
|
||||
@ -370,7 +370,7 @@ class CommandDispatcher(QObject):
|
||||
else:
|
||||
mode = QClipboard.Clipboard
|
||||
target = "clipboard"
|
||||
logging.debug("Yanking to {}: '{}'".format(target, title))
|
||||
log.misc.debug("Yanking to {}: '{}'".format(target, title))
|
||||
QApplication.clipboard().setText(title, mode)
|
||||
message.info("Title yanked to {}".format(target))
|
||||
|
||||
@ -494,7 +494,7 @@ class CommandDispatcher(QObject):
|
||||
url = QApplication.clipboard().text(mode)
|
||||
if not url:
|
||||
raise CommandError("Clipboard is empty.")
|
||||
logging.debug("Clipboard contained: '{}'".format(url))
|
||||
log.misc.debug("Clipboard contained: '{}'".format(url))
|
||||
if tab:
|
||||
self._tabs.tabopen(url)
|
||||
else:
|
||||
@ -585,7 +585,7 @@ class CommandDispatcher(QObject):
|
||||
"""
|
||||
url = urlutils.urlstring(self._tabs.currentWidget().url())
|
||||
cmd = cmd.replace('{}', shell_escape(url))
|
||||
logging.debug("Executing: {}".format(cmd))
|
||||
log.procs.debug("Executing: {}".format(cmd))
|
||||
subprocess.Popen(cmd, shell=True)
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs.cmd')
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
"""A HintManager to draw hints over links."""
|
||||
|
||||
import logging
|
||||
import math
|
||||
from collections import namedtuple
|
||||
|
||||
@ -32,6 +31,7 @@ import qutebrowser.utils.url as urlutils
|
||||
import qutebrowser.utils.webelem as webelem
|
||||
from qutebrowser.commands.exceptions import CommandError
|
||||
from qutebrowser.utils.usertypes import enum
|
||||
from qutebrowser.utils.log import hints as logger
|
||||
|
||||
|
||||
ElemTuple = namedtuple('ElemTuple', 'elem, label')
|
||||
@ -266,8 +266,8 @@ class HintManager(QObject):
|
||||
# e.g. parse (-webkit-)border-radius correctly and click text fields at
|
||||
# the bottom right, and everything else on the top left or so.
|
||||
pos = webelem.rect_on_view(elem).center()
|
||||
logging.debug("Clicking on '{}' at {}/{}".format(elem.toPlainText(),
|
||||
pos.x(), pos.y()))
|
||||
logger.debug("Clicking on '{}' at {}/{}".format(elem.toPlainText(),
|
||||
pos.x(), pos.y()))
|
||||
events = [
|
||||
QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton,
|
||||
Qt.NoModifier),
|
||||
@ -356,9 +356,9 @@ class HintManager(QObject):
|
||||
# making sure we don't connect a frame which already was connected
|
||||
# at some point earlier.
|
||||
if f in self._connected_frames:
|
||||
logging.debug("Frame {} already connected!".format(f))
|
||||
logger.debug("Frame {} already connected!".format(f))
|
||||
else:
|
||||
logging.debug("Connecting frame {}".format(f))
|
||||
logger.debug("Connecting frame {}".format(f))
|
||||
f.contentsSizeChanged.connect(self.on_contents_size_changed)
|
||||
self._connected_frames.append(f)
|
||||
|
||||
@ -422,7 +422,7 @@ class HintManager(QObject):
|
||||
|
||||
def handle_partial_key(self, keystr):
|
||||
"""Handle a new partial keypress."""
|
||||
logging.debug("Handling new keystring: '{}'".format(keystr))
|
||||
logger.debug("Handling new keystring: '{}'".format(keystr))
|
||||
for (string, elems) in self._elems.items():
|
||||
if string.startswith(keystr):
|
||||
matched = string[:len(keystr)]
|
||||
@ -516,9 +516,9 @@ class HintManager(QObject):
|
||||
if not self._started:
|
||||
# We got here because of some earlier hinting, but we can't simply
|
||||
# disconnect frames as this leads to occasional segfaults :-/
|
||||
logging.debug("Not hinting!")
|
||||
logger.debug("Not hinting!")
|
||||
return
|
||||
logging.debug("Contents size changed...!")
|
||||
logger.debug("Contents size changed...!")
|
||||
for elems in self._elems.values():
|
||||
css = self._get_hint_css(elems.elem, elems.label)
|
||||
elems.label.setAttribute('style', css)
|
||||
|
@ -17,13 +17,13 @@
|
||||
|
||||
"""A filter for signals which either filters or passes them."""
|
||||
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.QtCore import QObject
|
||||
|
||||
from qutebrowser.utils.signals import dbg_signal
|
||||
from qutebrowser.widgets.webview import WebView
|
||||
from qutebrowser.utils.log import signals as logger
|
||||
|
||||
|
||||
class SignalFilter(QObject):
|
||||
@ -72,15 +72,15 @@ class SignalFilter(QObject):
|
||||
log_signal = not signal.signal.startswith('2cur_progress')
|
||||
if not isinstance(sender, WebView):
|
||||
# BUG? This should never happen, but it does regularely...
|
||||
logging.warn("Got signal {} by {} which is no tab!".format(
|
||||
logger.warn("Got signal {} by {} which is no tab!".format(
|
||||
dbg_signal(signal, args), sender))
|
||||
return
|
||||
if self._tabs.currentWidget() == sender:
|
||||
if log_signal:
|
||||
logging.debug("emitting: {} (tab {})".format(
|
||||
logger.debug("emitting: {} (tab {})".format(
|
||||
dbg_signal(signal, args), self._tabs.indexOf(sender)))
|
||||
signal.emit(*args)
|
||||
else:
|
||||
if log_signal:
|
||||
logging.debug("ignoring: {} (tab {})".format(
|
||||
logger.debug("ignoring: {} (tab {})".format(
|
||||
dbg_signal(signal, args), self._tabs.indexOf(sender)))
|
||||
|
@ -17,14 +17,13 @@
|
||||
|
||||
"""Contains the Command class, a skeleton for a command."""
|
||||
|
||||
import logging
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
from PyQt5.QtWebKit import QWebSettings
|
||||
|
||||
from qutebrowser.commands.exceptions import (ArgumentCountError,
|
||||
PrerequisitesError)
|
||||
from qutebrowser.utils.misc import dotted_getattr
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
from PyQt5.QtWebKit import QWebSettings
|
||||
from qutebrowser.utils.log import commands as logger
|
||||
|
||||
|
||||
class Command:
|
||||
@ -120,7 +119,7 @@ class Command:
|
||||
dbgout += args
|
||||
if count is not None:
|
||||
dbgout.append("(count={})".format(count))
|
||||
logging.debug(' '.join(dbgout))
|
||||
logger.debug(' '.join(dbgout))
|
||||
|
||||
kwargs = {}
|
||||
app = QCoreApplication.instance()
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
"""Module containing command managers (SearchManager and CommandManager)."""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
|
||||
from PyQt5.QtWebKitWidgets import QWebPage
|
||||
|
||||
@ -28,6 +26,7 @@ import qutebrowser.utils.message as message
|
||||
from qutebrowser.commands.exceptions import (NoSuchCommandError,
|
||||
CommandMetaError, CommandError)
|
||||
from qutebrowser.utils.misc import safe_shlex_split
|
||||
from qutebrowser.utils.log import commands as logger
|
||||
|
||||
|
||||
def split_cmdline(text):
|
||||
@ -39,7 +38,7 @@ def split_cmdline(text):
|
||||
Return:
|
||||
A list of strings.
|
||||
"""
|
||||
logging.debug("Splitting '{}'".format(text))
|
||||
logger.debug("Splitting '{}'".format(text))
|
||||
manager = CommandManager()
|
||||
original_cmd = text.strip().split(maxsplit=1)
|
||||
try:
|
||||
@ -48,7 +47,7 @@ def split_cmdline(text):
|
||||
parts = text.split(' ')
|
||||
if text.endswith(' '):
|
||||
parts.append('')
|
||||
logging.debug("Split parts: {}".format(parts))
|
||||
logger.debug("Split parts: {}".format(parts))
|
||||
if len(parts) == 1 and parts[0]:
|
||||
parts = original_cmd
|
||||
return parts
|
||||
@ -195,7 +194,7 @@ class CommandManager:
|
||||
new_cmd = alias
|
||||
if text.endswith(' '):
|
||||
new_cmd += ' '
|
||||
logging.debug("Re-parsing with '{}'.".format(new_cmd))
|
||||
logger.debug("Re-parsing with '{}'.".format(new_cmd))
|
||||
return self.parse(new_cmd, aliases=False)
|
||||
try:
|
||||
cmd = cmdutils.cmd_dict[cmdstr]
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import logging
|
||||
import tempfile
|
||||
from select import select
|
||||
|
||||
@ -28,6 +27,7 @@ from PyQt5.QtCore import (pyqtSignal, QObject, QThread, QStandardPaths,
|
||||
|
||||
import qutebrowser.utils.message as message
|
||||
from qutebrowser.utils.misc import get_standard_dir
|
||||
from qutebrowser.utils.log import procs as logger
|
||||
|
||||
|
||||
class _BlockingFIFOReader(QObject):
|
||||
@ -67,10 +67,10 @@ class _BlockingFIFOReader(QObject):
|
||||
fd = os.open(self.filepath, os.O_RDWR | os.O_NONBLOCK)
|
||||
self.fifo = os.fdopen(fd, 'r')
|
||||
while True:
|
||||
logging.debug("thread loop")
|
||||
logger.debug("thread loop")
|
||||
ready_r, _ready_w, _ready_e = select([self.fifo], [], [], 1)
|
||||
if ready_r:
|
||||
logging.debug("reading data")
|
||||
logger.debug("reading data")
|
||||
for line in self.fifo:
|
||||
self.got_line.emit(line.rstrip())
|
||||
if QThread.currentThread().isInterruptionRequested():
|
||||
@ -206,7 +206,7 @@ class _POSIXUserscriptRunner(_BaseUserscriptRunner):
|
||||
|
||||
def on_proc_finished(self):
|
||||
"""Interrupt the reader when the process finished."""
|
||||
logging.debug("proc finished")
|
||||
logger.debug("proc finished")
|
||||
self.thread.requestInterruption()
|
||||
|
||||
def on_proc_error(self, error):
|
||||
@ -216,7 +216,7 @@ class _POSIXUserscriptRunner(_BaseUserscriptRunner):
|
||||
|
||||
def on_reader_finished(self):
|
||||
"""Quit the thread and clean up when the reader finished."""
|
||||
logging.debug("reader finished")
|
||||
logger.debug("reader finished")
|
||||
self.thread.quit()
|
||||
self.reader.fifo.close()
|
||||
self.reader.deleteLater()
|
||||
@ -224,7 +224,7 @@ class _POSIXUserscriptRunner(_BaseUserscriptRunner):
|
||||
|
||||
def on_thread_finished(self):
|
||||
"""Clean up the QThread object when the thread finished."""
|
||||
logging.debug("thread finished")
|
||||
logger.debug("thread finished")
|
||||
self.thread.deleteLater()
|
||||
|
||||
|
||||
@ -257,7 +257,7 @@ class _WindowsUserscriptRunner(_BaseUserscriptRunner):
|
||||
Emit:
|
||||
got_cmd: Emitted for every command in the file.
|
||||
"""
|
||||
logging.debug("proc finished")
|
||||
logger.debug("proc finished")
|
||||
with open(self.filepath, 'r') as f:
|
||||
for line in f:
|
||||
self.got_cmd.emit(line.rstrip())
|
||||
|
@ -24,7 +24,6 @@ we borrow some methods and classes from there where it makes sense.
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import logging
|
||||
import textwrap
|
||||
import configparser
|
||||
from configparser import ExtendedInterpolation
|
||||
@ -35,6 +34,7 @@ from PyQt5.QtCore import pyqtSignal, QObject, QCoreApplication
|
||||
import qutebrowser.config.configdata as configdata
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
import qutebrowser.utils.message as message
|
||||
import qutebrowser.utils.log as log
|
||||
from qutebrowser.config.iniparsers import ReadConfigParser
|
||||
from qutebrowser.config._conftypes import ValidationError
|
||||
from qutebrowser.commands.exceptions import CommandError
|
||||
@ -356,7 +356,7 @@ class ConfigManager(QObject):
|
||||
"""Save the config file."""
|
||||
if not os.path.exists(self._configdir):
|
||||
os.makedirs(self._configdir, 0o755)
|
||||
logging.debug("Saving config to {}".format(self._configfile))
|
||||
log.destroy.debug("Saving config to {}".format(self._configfile))
|
||||
with open(self._configfile, 'w', encoding='utf-8') as f:
|
||||
f.write(str(self))
|
||||
|
||||
|
@ -19,9 +19,10 @@
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import logging
|
||||
from configparser import ConfigParser
|
||||
|
||||
import qutebrowser.utils.log as log
|
||||
|
||||
|
||||
class ReadConfigParser(ConfigParser):
|
||||
|
||||
@ -45,7 +46,7 @@ class ReadConfigParser(ConfigParser):
|
||||
self._configfile = os.path.join(self._configdir, fname)
|
||||
if not os.path.isfile(self._configfile):
|
||||
return
|
||||
logging.debug("Reading config from {}".format(self._configfile))
|
||||
log.init.debug("Reading config from {}".format(self._configfile))
|
||||
self.read(self._configfile, encoding='utf-8')
|
||||
|
||||
|
||||
@ -57,6 +58,6 @@ class ReadWriteConfigParser(ReadConfigParser):
|
||||
"""Save the config file."""
|
||||
if not os.path.exists(self._configdir):
|
||||
os.makedirs(self._configdir, 0o755)
|
||||
logging.debug("Saving config to {}".format(self._configfile))
|
||||
log.destroy.debug("Saving config to {}".format(self._configfile))
|
||||
with open(self._configfile, 'w', encoding='utf-8') as f:
|
||||
self.write(f)
|
||||
|
@ -19,10 +19,11 @@
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
|
||||
import qutebrowser.utils.log as log
|
||||
|
||||
|
||||
class LineConfigParser:
|
||||
|
||||
@ -48,7 +49,7 @@ class LineConfigParser:
|
||||
if not os.path.isfile(self._configfile):
|
||||
self.data = []
|
||||
else:
|
||||
logging.debug("Reading config from {}".format(self._configfile))
|
||||
log.init.debug("Reading config from {}".format(self._configfile))
|
||||
self.read(self._configfile)
|
||||
|
||||
def __iter__(self):
|
||||
@ -76,7 +77,7 @@ class LineConfigParser:
|
||||
def save(self):
|
||||
"""Save the config file."""
|
||||
if not self.data:
|
||||
logging.debug("No data to save.")
|
||||
log.destroy.debug("No data to save.")
|
||||
return
|
||||
# We need to import this here because config needs LineConfigParser.
|
||||
import qutebrowser.config.config as config
|
||||
@ -85,7 +86,7 @@ class LineConfigParser:
|
||||
return
|
||||
if not os.path.exists(self._configdir):
|
||||
os.makedirs(self._configdir, 0o755)
|
||||
logging.debug("Saving config to {}".format(self._configfile))
|
||||
log.destroy.debug("Saving config to {}".format(self._configfile))
|
||||
with open(self._configfile, 'w', encoding='utf-8') as f:
|
||||
self.write(f, limit)
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
import re
|
||||
import string
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QObject, QTimer
|
||||
@ -27,6 +26,7 @@ from PyQt5.QtGui import QKeySequence
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
from qutebrowser.utils.usertypes import enum
|
||||
from qutebrowser.utils.log import keyboard as logger
|
||||
|
||||
|
||||
class BaseKeyParser(QObject):
|
||||
@ -134,7 +134,7 @@ class BaseKeyParser(QObject):
|
||||
try:
|
||||
cmdstr = self.special_bindings[modstr + keystr]
|
||||
except KeyError:
|
||||
logging.debug("No binding found for {}.".format(modstr + keystr))
|
||||
logger.debug("No binding found for {}.".format(modstr + keystr))
|
||||
return False
|
||||
self.execute(cmdstr, self.Type.special)
|
||||
return True
|
||||
@ -169,17 +169,17 @@ class BaseKeyParser(QObject):
|
||||
"""
|
||||
txt = e.text()
|
||||
key = e.key()
|
||||
logging.debug("Got key: {} / text: '{}'".format(key, txt))
|
||||
logger.debug("Got key: {} / text: '{}'".format(key, txt))
|
||||
|
||||
if key == Qt.Key_Escape:
|
||||
logging.debug("Escape pressed, discarding '{}'.".format(
|
||||
logger.debug("Escape pressed, discarding '{}'.".format(
|
||||
self._keystring))
|
||||
self._keystring = ''
|
||||
return
|
||||
|
||||
if txt not in (string.ascii_letters + string.digits +
|
||||
string.punctuation):
|
||||
logging.debug("Ignoring, no text char")
|
||||
logger.debug("Ignoring, no text char")
|
||||
return False
|
||||
|
||||
self._stop_delayed_exec()
|
||||
@ -194,17 +194,17 @@ class BaseKeyParser(QObject):
|
||||
match, binding = self._match_key(cmd_input)
|
||||
|
||||
if match == self.Match.definitive:
|
||||
logging.debug("Definitive match for '{}'.".format(self._keystring))
|
||||
logger.debug("Definitive match for '{}'.".format(self._keystring))
|
||||
self._keystring = ''
|
||||
self.execute(binding, self.Type.chain, count)
|
||||
elif match == self.Match.ambiguous:
|
||||
logging.debug("Ambigious match for '{}'.".format(self._keystring))
|
||||
logger.debug("Ambigious match for '{}'.".format(self._keystring))
|
||||
self._handle_ambiguous_match(binding, count)
|
||||
elif match == self.Match.partial:
|
||||
logging.debug("No match for '{}' (added {})".format(
|
||||
logger.debug("No match for '{}' (added {})".format(
|
||||
self._keystring, txt))
|
||||
elif match == self.Match.none:
|
||||
logging.debug("Giving up with '{}', no matches".format(
|
||||
logger.debug("Giving up with '{}', no matches".format(
|
||||
self._keystring))
|
||||
self._keystring = ''
|
||||
return False
|
||||
@ -252,7 +252,7 @@ class BaseKeyParser(QObject):
|
||||
def _stop_delayed_exec(self):
|
||||
"""Stop a delayed execution if any is running."""
|
||||
if self._timer is not None:
|
||||
logging.debug("Stopping delayed execution.")
|
||||
logger.debug("Stopping delayed execution.")
|
||||
self._timer.stop()
|
||||
self._timer = None
|
||||
|
||||
@ -263,7 +263,7 @@ class BaseKeyParser(QObject):
|
||||
binding: The command-string to execute.
|
||||
count: The count to pass.
|
||||
"""
|
||||
logging.debug("Ambiguous match for '{}'".format(self._keystring))
|
||||
logger.debug("Ambiguous match for '{}'".format(self._keystring))
|
||||
time = config.get('input', 'timeout')
|
||||
if time == 0:
|
||||
# execute immediately
|
||||
@ -271,8 +271,8 @@ class BaseKeyParser(QObject):
|
||||
self.execute(binding, self.Type.chain, count)
|
||||
else:
|
||||
# execute in `time' ms
|
||||
logging.debug("Scheduling execution of {} in {}ms".format(binding,
|
||||
time))
|
||||
logger.debug("Scheduling execution of {} in {}ms".format(binding,
|
||||
time))
|
||||
self._timer = QTimer(self)
|
||||
self._timer.setSingleShot(True)
|
||||
self._timer.setInterval(time)
|
||||
@ -289,7 +289,7 @@ class BaseKeyParser(QObject):
|
||||
Emit:
|
||||
keystring_updated to do a delayed update.
|
||||
"""
|
||||
logging.debug("Executing delayed command now!")
|
||||
logger.debug("Executing delayed command now!")
|
||||
self._timer = None
|
||||
self._keystring = ''
|
||||
self.keystring_updated.emit(self._keystring)
|
||||
@ -331,20 +331,20 @@ class BaseKeyParser(QObject):
|
||||
self.special_bindings = {}
|
||||
sect = config.section(sectname)
|
||||
if not sect.items():
|
||||
logging.warning("No keybindings defined!")
|
||||
logger.warning("No keybindings defined!")
|
||||
for (key, cmd) in sect.items():
|
||||
if not cmd:
|
||||
continue
|
||||
elif key.startswith('<') and key.endswith('>'):
|
||||
keystr = self._normalize_keystr(key[1:-1])
|
||||
logging.debug("registered special key: {} -> {}".format(keystr,
|
||||
cmd))
|
||||
logger.debug("registered special key: {} -> {}".format(keystr,
|
||||
cmd))
|
||||
self.special_bindings[keystr] = cmd
|
||||
elif self._supports_chains:
|
||||
logging.debug("registered key: {} -> {}".format(key, cmd))
|
||||
logger.debug("registered key: {} -> {}".format(key, cmd))
|
||||
self.bindings[key] = cmd
|
||||
elif self.warn_on_keychains:
|
||||
logging.warning(
|
||||
logger.warning(
|
||||
"Ignoring keychain '{}' in section '{}' because "
|
||||
"keychains are not supported there.".format(key, sectname))
|
||||
|
||||
|
@ -17,14 +17,13 @@
|
||||
|
||||
"""Advanced keyparsers."""
|
||||
|
||||
import logging
|
||||
|
||||
from qutebrowser.keyinput._basekeyparser import BaseKeyParser
|
||||
import qutebrowser.utils.message as message
|
||||
|
||||
from qutebrowser.commands.managers import CommandManager
|
||||
from qutebrowser.commands.exceptions import (
|
||||
ArgumentCountError, CommandMetaError, CommandError)
|
||||
from qutebrowser.utils.log import keyboard as logger
|
||||
|
||||
|
||||
class CommandKeyParser(BaseKeyParser):
|
||||
@ -50,7 +49,7 @@ class CommandKeyParser(BaseKeyParser):
|
||||
try:
|
||||
self.commandmanager.run(cmdstr, count=count)
|
||||
except ArgumentCountError:
|
||||
logging.debug("Filling statusbar with partial command {}".format(
|
||||
logger.debug("Filling statusbar with partial command {}".format(
|
||||
cmdstr))
|
||||
message.set_cmd_text(':{} '.format(cmdstr))
|
||||
except (CommandMetaError, CommandError) as e:
|
||||
|
@ -21,8 +21,6 @@ Module attributes:
|
||||
manager: The ModeManager instance.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtGui import QWindow
|
||||
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, QObject, QEvent,
|
||||
QCoreApplication)
|
||||
@ -30,6 +28,7 @@ from PyQt5.QtCore import (pyqtSignal, pyqtSlot, QObject, QEvent,
|
||||
import qutebrowser.config.config as config
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
import qutebrowser.utils.debug as debug
|
||||
from qutebrowser.utils.log import modes as logger
|
||||
|
||||
|
||||
def instance():
|
||||
@ -120,7 +119,7 @@ class ModeManager(QObject):
|
||||
True if event should be filtered, False otherwise.
|
||||
"""
|
||||
handler = self._handlers[self.mode]
|
||||
logging.debug("calling handler {}".format(handler.__qualname__))
|
||||
logger.debug("calling handler {}".format(handler.__qualname__))
|
||||
handled = handler(event) if handler is not None else False
|
||||
|
||||
if handled:
|
||||
@ -133,11 +132,11 @@ class ModeManager(QObject):
|
||||
if not filter_this:
|
||||
self._releaseevents_to_pass.append(event)
|
||||
|
||||
logging.debug("handled: {}, forward-unbound-keys: {}, passthrough: {} "
|
||||
"--> filter: {}".format(handled,
|
||||
self._forward_unbound_keys,
|
||||
self.mode in self.passthrough,
|
||||
filter_this))
|
||||
logger.debug("handled: {}, forward-unbound-keys: {}, passthrough: {} "
|
||||
"--> filter: {}".format(handled,
|
||||
self._forward_unbound_keys,
|
||||
self.mode in self.passthrough,
|
||||
filter_this))
|
||||
return filter_this
|
||||
|
||||
def _eventFilter_keyrelease(self, event):
|
||||
@ -157,7 +156,7 @@ class ModeManager(QObject):
|
||||
filter_this = False
|
||||
else:
|
||||
filter_this = True
|
||||
logging.debug("filter: {}".format(filter_this))
|
||||
logger.debug("filter: {}".format(filter_this))
|
||||
return filter_this
|
||||
|
||||
def register(self, mode, handler, passthrough=False):
|
||||
@ -184,15 +183,15 @@ class ModeManager(QObject):
|
||||
Emit:
|
||||
entered: With the new mode name.
|
||||
"""
|
||||
logging.debug("Entering mode {}{}".format(
|
||||
logger.debug("Entering mode {}{}".format(
|
||||
mode, '' if reason is None else ' (reason: {})'.format(reason)))
|
||||
if mode not in self._handlers:
|
||||
raise ValueError("No handler for mode {}".format(mode))
|
||||
if self._mode_stack and self._mode_stack[-1] == mode:
|
||||
logging.debug("Already at end of stack, doing nothing")
|
||||
logger.debug("Already at end of stack, doing nothing")
|
||||
return
|
||||
self._mode_stack.append(mode)
|
||||
logging.debug("New mode stack: {}".format(self._mode_stack))
|
||||
logger.debug("New mode stack: {}".format(self._mode_stack))
|
||||
self.entered.emit(mode)
|
||||
|
||||
def leave(self, mode, reason=None):
|
||||
@ -209,7 +208,7 @@ class ModeManager(QObject):
|
||||
self._mode_stack.remove(mode)
|
||||
except ValueError:
|
||||
raise ValueError("Mode {} not on mode stack!".format(mode))
|
||||
logging.debug("Leaving mode {}{}, new mode stack {}".format(
|
||||
logger.debug("Leaving mode {}{}, new mode stack {}".format(
|
||||
mode, '' if reason is None else ' (reason: {})'.format(reason),
|
||||
self._mode_stack))
|
||||
self.left.emit(mode)
|
||||
@ -250,14 +249,14 @@ class ModeManager(QObject):
|
||||
if not isinstance(obj, QWindow):
|
||||
# We already handled this same event at some point earlier, so
|
||||
# we're not interested in it anymore.
|
||||
logging.debug("Ignoring event {} for {}".format(
|
||||
logger.debug("Ignoring event {} for {}".format(
|
||||
debug.EVENTS[typ], obj.__class__.__name__))
|
||||
return False
|
||||
if QCoreApplication.instance().activeWindow() is not self.mainwindow:
|
||||
# Some other window (print dialog, etc.) is focused so we pass
|
||||
# the event through.
|
||||
return False
|
||||
logging.debug("Got event {} for {} in mode {}".format(
|
||||
logger.debug("Got event {} for {} in mode {}".format(
|
||||
debug.EVENTS[typ], obj.__class__.__name__, self.mode))
|
||||
|
||||
if typ == QEvent.KeyPress:
|
||||
|
@ -21,14 +21,13 @@ Module attributes:
|
||||
STARTCHARS: Possible chars for starting a commandline input.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, Qt
|
||||
|
||||
import qutebrowser.utils.message as message
|
||||
import qutebrowser.config.config as config
|
||||
from qutebrowser.keyinput.keyparser import CommandKeyParser
|
||||
from qutebrowser.utils.usertypes import enum
|
||||
from qutebrowser.utils.log import keyboard as logger
|
||||
|
||||
|
||||
STARTCHARS = ":/?"
|
||||
@ -109,11 +108,11 @@ class HintKeyParser(CommandKeyParser):
|
||||
filter_hints: Emitted when filter string has changed.
|
||||
keystring_updated: Emitted when keystring has been changed.
|
||||
"""
|
||||
logging.debug("Got special key {} text {}".format(e.key(), e.text()))
|
||||
logger.debug("Got special key {} text {}".format(e.key(), e.text()))
|
||||
if e.key() == Qt.Key_Backspace:
|
||||
logging.debug("Got backspace, mode {}, filtertext '{}', keystring "
|
||||
"'{}'".format(LastPress[self._last_press],
|
||||
self._filtertext, self._keystring))
|
||||
logger.debug("Got backspace, mode {}, filtertext '{}', keystring "
|
||||
"'{}'".format(LastPress[self._last_press],
|
||||
self._filtertext, self._keystring))
|
||||
if self._last_press == LastPress.filtertext and self._filtertext:
|
||||
self._filtertext = self._filtertext[:-1]
|
||||
self.filter_hints.emit(self._filtertext)
|
||||
|
@ -17,11 +17,10 @@
|
||||
|
||||
"""Command history for the status bar."""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, QCoreApplication
|
||||
|
||||
from qutebrowser.utils.usertypes import NeighborList
|
||||
from qutebrowser.utils.log import statusbar as logger
|
||||
|
||||
|
||||
class HistoryEmptyError(Exception):
|
||||
@ -70,7 +69,7 @@ class History:
|
||||
Args:
|
||||
text: The preset text.
|
||||
"""
|
||||
logging.debug("Preset text: '{}'".format(text))
|
||||
logger.debug("Preset text: '{}'".format(text))
|
||||
if text:
|
||||
items = [e for e in self._history if e.startswith(text)]
|
||||
else:
|
||||
|
@ -21,10 +21,10 @@ Contains:
|
||||
CompletionFilterModel -- A QSortFilterProxyModel subclass for completions.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import QSortFilterProxyModel, QModelIndex
|
||||
|
||||
from qutebrowser.utils.log import completion as logger
|
||||
|
||||
|
||||
class CompletionFilterModel(QSortFilterProxyModel):
|
||||
|
||||
@ -85,7 +85,7 @@ class CompletionFilterModel(QSortFilterProxyModel):
|
||||
|
||||
def setSourceModel(self, model):
|
||||
"""Override QSortFilterProxyModel's setSourceModel to clear pattern."""
|
||||
logging.debug("Setting source model: {}".format(model))
|
||||
logger.debug("Setting source model: {}".format(model))
|
||||
self.pattern = ''
|
||||
self.srcmodel = model
|
||||
super().setSourceModel(model)
|
||||
|
@ -22,13 +22,13 @@ Module attributes:
|
||||
pyeval_output: The output of the last :pyeval command.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import cgi
|
||||
|
||||
from qutebrowser.network._schemehandler import (SchemeHandler,
|
||||
SpecialNetworkReply)
|
||||
from qutebrowser.utils.version import version
|
||||
from qutebrowser.utils.url import urlstring
|
||||
from qutebrowser.utils.log import misc as logger
|
||||
|
||||
|
||||
_HTML_TEMPLATE = """
|
||||
@ -87,7 +87,7 @@ class QuteSchemeHandler(SchemeHandler):
|
||||
Return:
|
||||
A QNetworkReply.
|
||||
"""
|
||||
logging.debug("request: {}".format(request))
|
||||
logger.debug("request: {}".format(request))
|
||||
url = urlstring(request.url())
|
||||
try:
|
||||
handler = getattr(QuteHandlers, self._transform_url(url))
|
||||
|
@ -18,11 +18,13 @@
|
||||
"""Utilities used for debugging."""
|
||||
|
||||
import sys
|
||||
import logging
|
||||
from functools import wraps
|
||||
|
||||
from PyQt5.QtCore import pyqtRemoveInputHook, QEvent
|
||||
|
||||
from qutebrowser.utils.log import misc as logger
|
||||
|
||||
|
||||
try:
|
||||
# pylint: disable=import-error
|
||||
from ipdb import set_trace as pdb_set_trace
|
||||
@ -42,8 +44,8 @@ def log_events(klass):
|
||||
@wraps(old_event)
|
||||
def new_event(self, e, *args, **kwargs):
|
||||
"""Wrapper for event() which logs events."""
|
||||
logging.debug("Event in {}: {}".format(klass.__name__,
|
||||
EVENTS[e.type()]))
|
||||
logger.debug("Event in {}: {}".format(klass.__name__,
|
||||
EVENTS[e.type()]))
|
||||
return old_event(self, e, *args, **kwargs)
|
||||
|
||||
klass.event = new_event
|
||||
|
@ -18,13 +18,13 @@
|
||||
"""Launcher for an external editor."""
|
||||
|
||||
import os
|
||||
import logging
|
||||
from tempfile import mkstemp
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, QProcess, QObject
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
import qutebrowser.utils.message as message
|
||||
from qutebrowser.utils.log import procs as logger
|
||||
|
||||
|
||||
class ExternalEditor(QObject):
|
||||
@ -60,7 +60,7 @@ class ExternalEditor(QObject):
|
||||
Emit:
|
||||
editing_finished: If process exited normally.
|
||||
"""
|
||||
logging.debug("Editor closed")
|
||||
logger.debug("Editor closed")
|
||||
if exitcode != 0:
|
||||
message.error("Editor did quit abnormally (status {})!".format(
|
||||
exitcode))
|
||||
@ -70,7 +70,7 @@ class ExternalEditor(QObject):
|
||||
return
|
||||
with open(self.filename, 'r') as f:
|
||||
text = ''.join(f.readlines())
|
||||
logging.debug("Read back: {}".format(text))
|
||||
logger.debug("Read back: {}".format(text))
|
||||
self._cleanup()
|
||||
self.editing_finished.emit(text)
|
||||
|
||||
@ -111,5 +111,5 @@ class ExternalEditor(QObject):
|
||||
editor = config.get('general', 'editor')
|
||||
executable = editor[0]
|
||||
args = [arg.replace('{}', self.filename) for arg in editor[1:]]
|
||||
logging.debug("Calling \"{}\" with args {}".format(executable, args))
|
||||
logger.debug("Calling \"{}\" with args {}".format(executable, args))
|
||||
self.proc.start(executable, args)
|
||||
|
37
qutebrowser/utils/log.py
Normal file
37
qutebrowser/utils/log.py
Normal file
@ -0,0 +1,37 @@
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Loggers and utilities related to logging."""
|
||||
|
||||
from logging import getLogger
|
||||
|
||||
# The different loggers used.
|
||||
|
||||
statusbar = getLogger('statusbar')
|
||||
completion = getLogger('completion')
|
||||
destroy = getLogger('destroy')
|
||||
modes = getLogger('modes')
|
||||
webview = getLogger('webview')
|
||||
mouse = getLogger('mouse')
|
||||
misc = getLogger('misc')
|
||||
url = getLogger('url')
|
||||
procs = getLogger('procs')
|
||||
commands = getLogger('commands')
|
||||
init = getLogger('init')
|
||||
signals = getLogger('signals')
|
||||
hints = getLogger('hints')
|
||||
keyboard = getLogger('keyboard')
|
@ -17,11 +17,10 @@
|
||||
|
||||
"""Message singleton so we don't have to define unneeded signals."""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSignal, QCoreApplication
|
||||
|
||||
from qutebrowser.utils.usertypes import PromptMode, Question
|
||||
from qutebrowser.utils.log import misc as logger
|
||||
|
||||
|
||||
def instance():
|
||||
@ -38,7 +37,7 @@ def error(message, queue=False):
|
||||
immediately.
|
||||
"""
|
||||
message = str(message)
|
||||
logging.error(message)
|
||||
logger.error(message)
|
||||
instance().error.emit(message, queue)
|
||||
|
||||
|
||||
@ -51,14 +50,14 @@ def info(message, queue=False):
|
||||
immediately.
|
||||
"""
|
||||
message = str(message)
|
||||
logging.info(message)
|
||||
logger.info(message)
|
||||
instance().info.emit(message, queue)
|
||||
|
||||
|
||||
def text(message):
|
||||
"""Display a persistent message in the statusbar."""
|
||||
message = str(message)
|
||||
logging.debug(message)
|
||||
logger.debug(message)
|
||||
instance().text.emit(message)
|
||||
|
||||
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
import re
|
||||
import os.path
|
||||
import logging
|
||||
import urllib.parse
|
||||
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtNetwork import QHostInfo
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
from qutebrowser.utils.log import url as logger
|
||||
|
||||
|
||||
# FIXME: we probably could raise some exceptions on invalid URLs
|
||||
@ -43,7 +43,7 @@ def _get_search_url(txt):
|
||||
Raise:
|
||||
SearchEngineError if there is no template or no search term was found.
|
||||
"""
|
||||
logging.debug("Finding search engine for '{}'".format(txt))
|
||||
logger.debug("Finding search engine for '{}'".format(txt))
|
||||
r = re.compile(r'(^|\s+)!(\w+)($|\s+)')
|
||||
m = r.search(txt)
|
||||
if m:
|
||||
@ -54,11 +54,11 @@ def _get_search_url(txt):
|
||||
raise SearchEngineError("Search engine {} not found!".format(
|
||||
engine))
|
||||
term = r.sub('', txt)
|
||||
logging.debug("engine {}, term '{}'".format(engine, term))
|
||||
logger.debug("engine {}, term '{}'".format(engine, term))
|
||||
else:
|
||||
template = config.get('searchengines', 'DEFAULT')
|
||||
term = txt
|
||||
logging.debug("engine: default, term '{}'".format(txt))
|
||||
logger.debug("engine: default, term '{}'".format(txt))
|
||||
if not term:
|
||||
raise SearchEngineError("No search term given")
|
||||
return QUrl.fromUserInput(template.format(urllib.parse.quote(term)))
|
||||
@ -101,7 +101,7 @@ def _is_url_dns(url):
|
||||
True if the URL really is a URL, False otherwise.
|
||||
"""
|
||||
host = url.host()
|
||||
logging.debug("DNS request for {}".format(host))
|
||||
logger.debug("DNS request for {}".format(host))
|
||||
if not host:
|
||||
return False
|
||||
info = QHostInfo.fromName(host)
|
||||
@ -144,16 +144,16 @@ def fuzzy_url(url):
|
||||
urlstr = urlstring(url)
|
||||
if is_url(urlstr):
|
||||
# probably an address
|
||||
logging.debug("URL is a fuzzy address")
|
||||
logger.debug("URL is a fuzzy address")
|
||||
newurl = QUrl.fromUserInput(urlstr)
|
||||
else: # probably a search term
|
||||
logging.debug("URL is a fuzzy search term")
|
||||
logger.debug("URL is a fuzzy search term")
|
||||
try:
|
||||
newurl = _get_search_url(urlstr)
|
||||
except ValueError: # invalid search engine
|
||||
newurl = QUrl.fromUserInput(urlstr)
|
||||
logging.debug("Converting fuzzy term {} to URL -> {}".format(
|
||||
urlstr, urlstring(newurl)))
|
||||
logger.debug("Converting fuzzy term {} to URL -> {}".format(
|
||||
urlstr, urlstring(newurl)))
|
||||
return newurl
|
||||
|
||||
|
||||
@ -179,8 +179,8 @@ def is_url(url):
|
||||
|
||||
autosearch = config.get('general', 'auto-search')
|
||||
|
||||
logging.debug("Checking if '{}' is a URL (autosearch={}).".format(
|
||||
urlstr, autosearch))
|
||||
logger.debug("Checking if '{}' is a URL (autosearch={}).".format(
|
||||
urlstr, autosearch))
|
||||
|
||||
if not autosearch:
|
||||
# no autosearch, so everything is a URL.
|
||||
@ -188,20 +188,20 @@ def is_url(url):
|
||||
|
||||
if ' ' in urlstr:
|
||||
# A URL will never contain a space
|
||||
logging.debug("Contains space -> no URL")
|
||||
logger.debug("Contains space -> no URL")
|
||||
return False
|
||||
elif is_special_url(url):
|
||||
# Special URLs are always URLs, even with autosearch=False
|
||||
logging.debug("Is an special URL.")
|
||||
logger.debug("Is an special URL.")
|
||||
return True
|
||||
elif os.path.exists(url):
|
||||
# local file
|
||||
return True
|
||||
elif autosearch == 'dns':
|
||||
logging.debug("Checking via DNS")
|
||||
logger.debug("Checking via DNS")
|
||||
return _is_url_dns(QUrl.fromUserInput(urlstr))
|
||||
elif autosearch == 'naive':
|
||||
logging.debug("Checking via naive check")
|
||||
logger.debug("Checking via naive check")
|
||||
return _is_url_naive(url)
|
||||
else:
|
||||
raise ValueError("Invalid autosearch value")
|
||||
|
@ -22,11 +22,12 @@ Module attributes:
|
||||
"""
|
||||
|
||||
import operator
|
||||
import logging
|
||||
import collections.abc
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, QObject
|
||||
|
||||
from qutebrowser.utils.log import misc as logger
|
||||
|
||||
|
||||
_UNSET = object()
|
||||
|
||||
@ -174,8 +175,8 @@ class NeighborList(collections.abc.Sequence):
|
||||
IndexError if the border of the list is reached and mode is
|
||||
exception.
|
||||
"""
|
||||
logging.debug("{} items, idx {}, offset {}".format(len(self._items),
|
||||
self.idx, offset))
|
||||
logger.debug("{} items, idx {}, offset {}".format(len(self._items),
|
||||
self.idx, offset))
|
||||
if not self._items:
|
||||
raise IndexError("No items found!")
|
||||
if self.fuzzyval is not None:
|
||||
|
@ -21,8 +21,6 @@ Defines a CompletionView which uses CompletionFiterModel and CompletionModel
|
||||
subclasses to provide completions.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtWidgets import QStyle, QTreeView, QSizePolicy
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QItemSelectionModel
|
||||
|
||||
@ -38,6 +36,7 @@ from qutebrowser.models.completion import (
|
||||
CommandCompletionModel, SettingSectionCompletionModel,
|
||||
SettingOptionCompletionModel, SettingValueCompletionModel)
|
||||
from qutebrowser.utils.usertypes import FakeDict
|
||||
from qutebrowser.utils.log import completion as logger
|
||||
|
||||
|
||||
class CompletionView(QTreeView):
|
||||
@ -216,14 +215,14 @@ class CompletionView(QTreeView):
|
||||
except KeyError:
|
||||
# entering an unknown command
|
||||
return None
|
||||
logging.debug("completions: {}".format(completions))
|
||||
logger.debug("completions: {}".format(completions))
|
||||
if completions is None:
|
||||
# command without any available completions
|
||||
return None
|
||||
try:
|
||||
idx = len(parts[1:]) - 1
|
||||
completion_name = completions[idx]
|
||||
logging.debug('partlen: {}, modelname {}'.format(
|
||||
logger.debug('partlen: {}, modelname {}'.format(
|
||||
len(parts[1:]), completion_name))
|
||||
except IndexError:
|
||||
# More arguments than completions
|
||||
@ -270,7 +269,7 @@ class CompletionView(QTreeView):
|
||||
Args:
|
||||
model: The model to use.
|
||||
"""
|
||||
logging.debug("Setting model to {}".format(model.__class__.__name__))
|
||||
logger.debug("Setting model to {}".format(model.__class__.__name__))
|
||||
self.setModel(model)
|
||||
self._model = model
|
||||
self.expandAll()
|
||||
@ -307,9 +306,9 @@ class CompletionView(QTreeView):
|
||||
|
||||
model = self._get_new_completion(parts)
|
||||
if model is None:
|
||||
logging.debug("No completion model for {}.".format(parts))
|
||||
logger.debug("No completion model for {}.".format(parts))
|
||||
else:
|
||||
logging.debug("New completion: {} / last: {}".format(
|
||||
logger.debug("New completion: {} / last: {}".format(
|
||||
model.srcmodel.__class__.__name__,
|
||||
self._lastmodel.srcmodel.__class__.__name__ if self._lastmodel
|
||||
is not None else "None"))
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
"""The main tabbed browser widget."""
|
||||
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.QtWidgets import QSizePolicy
|
||||
@ -27,6 +26,7 @@ import qutebrowser.utils.url as urlutils
|
||||
import qutebrowser.config.config as config
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
import qutebrowser.keyinput.modeman as modeman
|
||||
import qutebrowser.utils.log as log
|
||||
from qutebrowser.widgets._tabwidget import TabWidget, EmptyTabIcon
|
||||
from qutebrowser.widgets.webview import WebView
|
||||
from qutebrowser.browser.signalfilter import SignalFilter
|
||||
@ -125,10 +125,10 @@ class TabbedBrowser(TabWidget):
|
||||
try:
|
||||
self._tabs.remove(tab)
|
||||
except ValueError:
|
||||
logging.exception("tab {} could not be removed".format(tab))
|
||||
logging.debug("Tabs after removing: {}".format(self._tabs))
|
||||
log.destroy.exception("tab {} could not be removed".format(tab))
|
||||
log.destroy.debug("Tabs after removing: {}".format(self._tabs))
|
||||
if not self._tabs: # all tabs shut down
|
||||
logging.debug("Tab shutdown complete.")
|
||||
log.destroy.debug("Tab shutdown complete.")
|
||||
self.shutdown_complete.emit()
|
||||
|
||||
def _connect_tab_signals(self, tab):
|
||||
@ -187,7 +187,7 @@ class TabbedBrowser(TabWidget):
|
||||
pass
|
||||
tabcount = self.count()
|
||||
if tabcount == 0:
|
||||
logging.debug("No tabs -> shutdown complete")
|
||||
log.destroy.debug("No tabs -> shutdown complete")
|
||||
self.shutdown_complete.emit()
|
||||
return
|
||||
for tab in self.widgets:
|
||||
@ -256,7 +256,7 @@ class TabbedBrowser(TabWidget):
|
||||
Return:
|
||||
The opened WebView instance.
|
||||
"""
|
||||
logging.debug("Creating new tab with URL {}".format(url))
|
||||
log.webview.debug("Creating new tab with URL {}".format(url))
|
||||
tab = WebView(self)
|
||||
self._connect_tab_signals(tab)
|
||||
self._tabs.append(tab)
|
||||
@ -328,11 +328,11 @@ class TabbedBrowser(TabWidget):
|
||||
Args:
|
||||
text: The text to set.
|
||||
"""
|
||||
logging.debug("title changed to '{}'".format(text))
|
||||
log.webview.debug("title changed to '{}'".format(text))
|
||||
if text:
|
||||
self.setTabText(self.indexOf(self.sender()), text)
|
||||
else:
|
||||
logging.debug("ignoring title change")
|
||||
log.webview.debug("ignoring title change")
|
||||
|
||||
@pyqtSlot(str)
|
||||
def on_url_text_changed(self, url):
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
"""The commandline in the statusbar."""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtWidgets import QSizePolicy
|
||||
from PyQt5.QtGui import QValidator
|
||||
@ -28,6 +26,7 @@ import qutebrowser.commands.utils as cmdutils
|
||||
from qutebrowser.widgets.misc import MinimalLineEdit
|
||||
from qutebrowser.commands.managers import split_cmdline
|
||||
from qutebrowser.keyinput.modeparsers import STARTCHARS
|
||||
from qutebrowser.utils.log import completion as logger
|
||||
from qutebrowser.models.cmdhistory import (History, HistoryEmptyError,
|
||||
HistoryEndReachedError)
|
||||
|
||||
@ -111,7 +110,7 @@ class Command(MinimalLineEdit):
|
||||
else:
|
||||
prefix = ''
|
||||
parts = split_cmdline(text)
|
||||
logging.debug("Old text: '{}' - parts: '{}', changing to '{}".format(
|
||||
logger.debug("Old text: '{}' - parts: '{}', changing to '{}".format(
|
||||
text, parts, newtext))
|
||||
parts[-1] = newtext
|
||||
self.setText(prefix + ' '.join(parts))
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
"""The main statusbar widget."""
|
||||
|
||||
import logging
|
||||
from collections import deque
|
||||
from datetime import datetime
|
||||
|
||||
@ -26,6 +25,7 @@ from PyQt5.QtWidgets import QWidget, QHBoxLayout, QStackedLayout, QSizePolicy
|
||||
|
||||
import qutebrowser.keyinput.modeman as modeman
|
||||
import qutebrowser.config.config as config
|
||||
from qutebrowser.utils.log import statusbar as logger
|
||||
from qutebrowser.widgets.statusbar._command import Command
|
||||
from qutebrowser.widgets.statusbar._progress import Progress
|
||||
from qutebrowser.widgets.statusbar._text import Text
|
||||
@ -172,9 +172,9 @@ class StatusBar(QWidget):
|
||||
self.txt.temptext = ''
|
||||
self._text_pop_timer.stop()
|
||||
return
|
||||
logging.debug("Displaying {} message: {}".format(
|
||||
logger.debug("Displaying {} message: {}".format(
|
||||
'error' if error else 'text', text))
|
||||
logging.debug("Remaining: {}".format(self._text_queue))
|
||||
logger.debug("Remaining: {}".format(self._text_queue))
|
||||
self.error = error
|
||||
self.txt.temptext = text
|
||||
|
||||
@ -188,7 +188,7 @@ class StatusBar(QWidget):
|
||||
|
||||
def _hide_cmd_widget(self):
|
||||
"""Show temporary text instead of command widget."""
|
||||
logging.debug("Hiding cmd widget, queue: {}".format(self._text_queue))
|
||||
logger.debug("Hiding cmd widget, queue: {}".format(self._text_queue))
|
||||
if self._timer_was_active:
|
||||
# Restart the text pop timer if it was active before hiding.
|
||||
self._pop_text()
|
||||
@ -206,7 +206,7 @@ class StatusBar(QWidget):
|
||||
|
||||
def _hide_prompt_widget(self):
|
||||
"""Show temporary text instead of prompt widget."""
|
||||
logging.debug("Hiding prompt widget, queue: {}".format(
|
||||
logger.debug("Hiding prompt widget, queue: {}".format(
|
||||
self._text_queue))
|
||||
if self._timer_was_active:
|
||||
# Restart the text pop timer if it was active before hiding.
|
||||
@ -224,40 +224,40 @@ class StatusBar(QWidget):
|
||||
queue: If set, message gets queued rather than being displayed
|
||||
immediately.
|
||||
"""
|
||||
logging.debug("Displaying text: {} (error={})".format(text, error))
|
||||
logger.debug("Displaying text: {} (error={})".format(text, error))
|
||||
now = datetime.now()
|
||||
mindelta = config.get('ui', 'message-timeout')
|
||||
delta = (None if self._last_text_time is None
|
||||
else now - self._last_text_time)
|
||||
self._last_text_time = now
|
||||
logging.debug("queue: {} / delta: {}".format(self._text_queue, delta))
|
||||
logger.debug("queue: {} / delta: {}".format(self._text_queue, delta))
|
||||
if not self._text_queue and (delta is None or delta.total_seconds() *
|
||||
1000.0 > mindelta):
|
||||
# If the queue is empty and we didn't print messages for long
|
||||
# enough, we can take the short route and display the message
|
||||
# immediately. We then start the pop_timer only to restore the
|
||||
# normal state in 2 seconds.
|
||||
logging.debug("Displaying immediately")
|
||||
logger.debug("Displaying immediately")
|
||||
self.error = error
|
||||
self.txt.temptext = text
|
||||
self._text_pop_timer.start()
|
||||
elif self._text_queue and self._text_queue[-1] == (error, text):
|
||||
# If we get the same message multiple times in a row and we're
|
||||
# still displaying it *anyways* we ignore the new one
|
||||
logging.debug("ignoring")
|
||||
logger.debug("ignoring")
|
||||
elif not queue:
|
||||
# This message is a reaction to a keypress and should be displayed
|
||||
# immediately, temporarely interrupting the message queue.
|
||||
# We display this immediately and restart the timer.to clear it and
|
||||
# display the rest of the queue later.
|
||||
logging.debug("Moving to beginning of queue")
|
||||
logger.debug("Moving to beginning of queue")
|
||||
self.error = error
|
||||
self.txt.temptext = text
|
||||
self._text_pop_timer.start()
|
||||
else:
|
||||
# There are still some messages to be displayed, so we queue this
|
||||
# up.
|
||||
logging.debug("queueing")
|
||||
logger.debug("queueing")
|
||||
self._text_queue.append((error, text))
|
||||
self._text_pop_timer.start()
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
"""The main browser widgets."""
|
||||
|
||||
import logging
|
||||
import functools
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt
|
||||
@ -30,6 +29,7 @@ import qutebrowser.config.config as config
|
||||
import qutebrowser.keyinput.modeman as modeman
|
||||
import qutebrowser.utils.message as message
|
||||
import qutebrowser.utils.webelem as webelem
|
||||
import qutebrowser.utils.log as log
|
||||
from qutebrowser.utils.misc import elide
|
||||
from qutebrowser.browser.webpage import BrowserPage
|
||||
from qutebrowser.browser.hints import HintManager
|
||||
@ -129,7 +129,7 @@ class WebView(QWebView):
|
||||
Emit:
|
||||
load_status_changed
|
||||
"""
|
||||
logging.debug("load status for {}: {}".format(
|
||||
log.webview.debug("load status for {}: {}".format(
|
||||
repr(self), LoadStatus[val]))
|
||||
self._load_status = val
|
||||
self.load_status_changed.emit(LoadStatus[val])
|
||||
@ -164,11 +164,11 @@ class WebView(QWebView):
|
||||
self._destroyed[sender] = True
|
||||
dbgout = '\n'.join(['{}: {}'.format(k.__class__.__name__, v)
|
||||
for (k, v) in self._destroyed.items()])
|
||||
logging.debug("{} has been destroyed, new status:\n{}".format(
|
||||
log.destroy.debug("{} has been destroyed, new status:\n{}".format(
|
||||
sender.__class__.__name__, dbgout))
|
||||
if all(self._destroyed.values()):
|
||||
if self._shutdown_callback is not None:
|
||||
logging.debug("Everything destroyed, calling callback")
|
||||
log.destroy.debug("Everything destroyed, calling callback")
|
||||
self._shutdown_callback()
|
||||
|
||||
def _is_editable(self, hitresult):
|
||||
@ -191,7 +191,7 @@ class WebView(QWebView):
|
||||
if tag == 'object':
|
||||
# Could be Flash/Java/..., could be image/audio/...
|
||||
if not elem.hasAttribute('type'):
|
||||
logging.debug("<object> without type clicked...")
|
||||
log.mouse.debug("<object> without type clicked...")
|
||||
return False
|
||||
objtype = elem.attribute('type')
|
||||
if (objtype.startswith('application/') or
|
||||
@ -199,7 +199,7 @@ class WebView(QWebView):
|
||||
# Let's hope flash/java stuff has an application/* mimetype OR
|
||||
# at least a classid attribute. Oh, and let's home images/...
|
||||
# DON"T have a classid attribute. HTML sucks.
|
||||
logging.debug("<object type='{}'> clicked.".format(objtype))
|
||||
log.mouse.debug("<object type='{}'> clicked.".format(objtype))
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -235,7 +235,7 @@ class WebView(QWebView):
|
||||
# This happens when we click inside the webview, but not actually
|
||||
# on the QWebPage - for example when clicking the scrollbar
|
||||
# sometimes.
|
||||
logging.debug("Clicked at {} but frame is None!".format(pos))
|
||||
log.mouse.debug("Clicked at {} but frame is None!".format(pos))
|
||||
return
|
||||
# You'd think we have to subtract frame.geometry().topLeft() from the
|
||||
# position, but it seems QWebFrame::hitTestContent wants a position
|
||||
@ -243,10 +243,10 @@ class WebView(QWebView):
|
||||
# me, but it works this way.
|
||||
hitresult = frame.hitTestContent(pos)
|
||||
if self._is_editable(hitresult):
|
||||
logging.debug("Clicked editable element!")
|
||||
log.mouse.debug("Clicked editable element!")
|
||||
modeman.enter('insert', 'click')
|
||||
else:
|
||||
logging.debug("Clicked non-editable element!")
|
||||
log.mouse.debug("Clicked non-editable element!")
|
||||
modeman.maybe_leave('insert', 'click')
|
||||
|
||||
def _mousepress_opentarget(self, e):
|
||||
@ -258,7 +258,7 @@ class WebView(QWebView):
|
||||
if self._force_open_target is not None:
|
||||
self._open_target = self._force_open_target
|
||||
self._force_open_target = None
|
||||
logging.debug("Setting force target: {}".format(
|
||||
log.mouse.debug("Setting force target: {}".format(
|
||||
Target[self._open_target]))
|
||||
elif (e.button() == Qt.MidButton or
|
||||
e.modifiers() & Qt.ControlModifier):
|
||||
@ -266,11 +266,11 @@ class WebView(QWebView):
|
||||
self._open_target = Target.tab_bg
|
||||
else:
|
||||
self._open_target = Target.tab
|
||||
logging.debug("Middle click, setting target: {}".format(
|
||||
log.mouse.debug("Middle click, setting target: {}".format(
|
||||
Target[self._open_target]))
|
||||
else:
|
||||
self._open_target = Target.normal
|
||||
logging.debug("Normal click, setting normal target")
|
||||
log.mouse.debug("Normal click, setting normal target")
|
||||
|
||||
def openurl(self, url):
|
||||
"""Open a URL in the browser.
|
||||
@ -288,7 +288,7 @@ class WebView(QWebView):
|
||||
u = urlutils.fuzzy_url(url)
|
||||
except urlutils.SearchEngineError as e:
|
||||
raise CommandError(e)
|
||||
logging.debug("New title: {}".format(urlutils.urlstring(u)))
|
||||
log.webview.debug("New title: {}".format(urlutils.urlstring(u)))
|
||||
self.titleChanged.emit(urlutils.urlstring(u))
|
||||
self.url_text = urlutils.urlstring(u)
|
||||
return self.load(u)
|
||||
@ -355,7 +355,7 @@ class WebView(QWebView):
|
||||
# Avoid loading finished signal when stopping
|
||||
self.loadFinished.disconnect()
|
||||
except TypeError:
|
||||
logging.exception("This should never happen.")
|
||||
log.destroy.exception("This should never happen.")
|
||||
self.stop()
|
||||
self.close()
|
||||
self.settings().setAttribute(QWebSettings.JavascriptEnabled, False)
|
||||
@ -368,7 +368,7 @@ class WebView(QWebView):
|
||||
self._destroyed[self] = False
|
||||
self.destroyed.connect(functools.partial(self._on_destroyed, self))
|
||||
self.deleteLater()
|
||||
logging.debug("Tab shutdown scheduled")
|
||||
log.destroy.debug("Tab shutdown scheduled")
|
||||
|
||||
@pyqtSlot('QUrl')
|
||||
def on_url_changed(self, url):
|
||||
@ -429,7 +429,7 @@ class WebView(QWebView):
|
||||
frame = self.page_.currentFrame()
|
||||
elem = frame.findFirstElement(
|
||||
webelem.SELECTORS[webelem.Group.editable_focused])
|
||||
logging.debug("focus element: {}".format(not elem.isNull()))
|
||||
log.modes.debug("focus element: {}".format(not elem.isNull()))
|
||||
if not elem.isNull():
|
||||
modeman.enter('insert', 'load finished')
|
||||
|
||||
@ -441,7 +441,7 @@ class WebView(QWebView):
|
||||
target: A string to set self._force_open_target to.
|
||||
"""
|
||||
t = getattr(Target, target)
|
||||
logging.debug("Setting force target to {}/{}".format(target, t))
|
||||
log.webview.debug("Setting force target to {}/{}".format(target, t))
|
||||
self._force_open_target = t
|
||||
|
||||
def createWindow(self, wintype):
|
||||
@ -464,8 +464,8 @@ class WebView(QWebView):
|
||||
The new QWebView object.
|
||||
"""
|
||||
if wintype == QWebPage.WebModalDialog:
|
||||
logging.warning("WebModalDialog requested, but we don't support "
|
||||
"that!")
|
||||
log.webview.warning("WebModalDialog requested, but we don't "
|
||||
"support that!")
|
||||
if config.get('general', 'window-open-behaviour') == 'new-tab':
|
||||
return self.tabbedbrowser.tabopen()
|
||||
else:
|
||||
@ -494,7 +494,7 @@ class WebView(QWebView):
|
||||
frame.scrollBarValue(Qt.Vertical))
|
||||
if self._old_scroll_pos != new_pos:
|
||||
self._old_scroll_pos = new_pos
|
||||
logging.debug("Updating scroll position")
|
||||
log.webview.debug("Updating scroll position")
|
||||
m = (frame.scrollBarMaximum(Qt.Horizontal),
|
||||
frame.scrollBarMaximum(Qt.Vertical))
|
||||
perc = (round(100 * new_pos[0] / m[0]) if m[0] != 0 else 0,
|
||||
|
Loading…
Reference in New Issue
Block a user