Improve logging messages
This commit is contained in:
parent
a3e5a20063
commit
a64775a0f9
@ -253,10 +253,11 @@ class Application(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.
|
||||
log.init.warn("Empty crash.log detected. This means either "
|
||||
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).")
|
||||
"of some earlier crash (then delete {}).".format(
|
||||
logname))
|
||||
self._crashlogfile = None
|
||||
else:
|
||||
# There's no log file, so we can use this to display crashes to the
|
||||
@ -446,7 +447,8 @@ class Application(QApplication):
|
||||
if url:
|
||||
pages.append(url)
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
log.init.debug(e)
|
||||
log.destroy.debug("Error while recovering tab: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
return pages
|
||||
|
||||
def _save_geometry(self):
|
||||
@ -486,7 +488,8 @@ class Application(QApplication):
|
||||
self.shutdown()
|
||||
return
|
||||
except Exception as e:
|
||||
log.destroy.debug(e)
|
||||
log.init.debug("Error while shutting down: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
self.quit()
|
||||
return
|
||||
|
||||
@ -498,36 +501,42 @@ class Application(QApplication):
|
||||
try:
|
||||
pages = self._recover_pages()
|
||||
except Exception as e:
|
||||
log.destroy.debug(e)
|
||||
log.destroy.debug("Error while recovering pages: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
pages = []
|
||||
|
||||
try:
|
||||
history = self.mainwindow.status.cmd.history[-5:]
|
||||
except Exception as e:
|
||||
log.destroy.debug(e)
|
||||
log.destroy.debug("Error while getting history: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
history = []
|
||||
|
||||
try:
|
||||
widgets = self.get_all_widgets()
|
||||
except Exception as e:
|
||||
log.destroy.debug(e)
|
||||
log.destroy.debug("Error while getting widgets: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
widgets = ""
|
||||
|
||||
try:
|
||||
objects = self.get_all_objects()
|
||||
except Exception as e:
|
||||
log.destroy.debug(e)
|
||||
log.destroy.debug("Error while getting objects: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
objects = ""
|
||||
|
||||
# Try to shutdown gracefully
|
||||
try:
|
||||
self.shutdown(do_quit=False)
|
||||
except Exception as e:
|
||||
log.destroy.debug(e)
|
||||
log.destroy.debug("Error while shutting down: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
try:
|
||||
self.lastWindowClosed.disconnect(self.shutdown)
|
||||
except TypeError as e:
|
||||
log.destroy.warning("Preventing shutdown failed ({}).")
|
||||
log.destroy.debug("Error while preventing shutdown: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
QApplication.closeAllWindows()
|
||||
self._crashdlg = ExceptionCrashDialog(pages, history, exc, widgets,
|
||||
objects)
|
||||
@ -575,7 +584,8 @@ class Application(QApplication):
|
||||
# try:
|
||||
# argv.remove(page)
|
||||
# except ValueError as e:
|
||||
# logger.destroy.debug(e)
|
||||
# logger.destroy.debug("Error while removing page: {}: "
|
||||
# "{}".format(e.__class__.__name__, e))
|
||||
# argv = [sys.executable] + argv + pages
|
||||
# log.procs.debug("Running {} with args {} (PYTHONPATH={})".format(
|
||||
# sys.executable, argv, pythonpath))
|
||||
|
@ -348,7 +348,8 @@ class DownloadManager(QObject):
|
||||
bytes(reply.rawHeader('Content-Disposition')))
|
||||
filename = content_disposition.filename_unsafe
|
||||
except UnicodeDecodeError as e:
|
||||
logger.warning(e)
|
||||
logger.warning("Error while getting filename: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
filename = None
|
||||
else:
|
||||
filename = None
|
||||
|
@ -197,8 +197,8 @@ class BrowserPage(QWebPage):
|
||||
"""
|
||||
try:
|
||||
handler = self._extension_handlers[ext]
|
||||
except KeyError as e:
|
||||
log.webview.warning(e)
|
||||
except KeyError:
|
||||
log.webview.warning("Extension {} not supported!".format(ext))
|
||||
return super().extension(ext, opt, out)
|
||||
return handler(opt, out)
|
||||
|
||||
|
@ -171,7 +171,8 @@ class ConfigManager(QObject):
|
||||
try:
|
||||
desc = self.sections[sectname].descriptions[optname]
|
||||
except KeyError as e:
|
||||
log.misc.debug(e)
|
||||
log.misc.debug("No description for {}.{}! ({}: {})".format(
|
||||
sectname, optname, e.__class__.__name__, e))
|
||||
continue
|
||||
for descline in desc.splitlines():
|
||||
lines += wrapper.wrap(descline)
|
||||
|
@ -30,7 +30,6 @@ from PyQt5.QtNetwork import QNetworkProxy
|
||||
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
from qutebrowser.utils.misc import get_standard_dir
|
||||
from qutebrowser.utils.log import misc as logger
|
||||
|
||||
|
||||
class ValidationError(ValueError):
|
||||
|
@ -107,7 +107,7 @@ class ColorDict(dict):
|
||||
try:
|
||||
val = super().__getitem__(key)
|
||||
except KeyError as e:
|
||||
logger.warning(e)
|
||||
logger.warning("No color defined for {}!".format(e))
|
||||
return ''
|
||||
if isinstance(val, QColor):
|
||||
# This could happen when accidentaly declarding something as
|
||||
|
@ -1,4 +1,4 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:)
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
@ -63,7 +63,9 @@ class SettingOptionCompletionModel(BaseCompletionModel):
|
||||
try:
|
||||
desc = sectdata.descriptions[name]
|
||||
except (KeyError, AttributeError) as e:
|
||||
logger.debug(e)
|
||||
logger.debug("Error while getting setting description for "
|
||||
"{}.{}: {}: {}".format(section, name,
|
||||
e.__class__.__name__, e))
|
||||
desc = ""
|
||||
value = config.get(section, name, raw=True)
|
||||
_valitem, _descitem, miscitem = self.new_item(cat, name, desc,
|
||||
@ -77,8 +79,9 @@ class SettingOptionCompletionModel(BaseCompletionModel):
|
||||
return
|
||||
try:
|
||||
item = self._misc_items[option]
|
||||
except KeyError as e:
|
||||
logger.debug(e)
|
||||
except KeyError:
|
||||
logger.debug("Couldn't get item {}.{} from model!".format(
|
||||
section, option))
|
||||
# changed before init
|
||||
return
|
||||
val = config.get(section, option, raw=True)
|
||||
|
@ -25,7 +25,6 @@ from PyQt5.QtWidgets import QApplication
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
from qutebrowser.utils.usertypes import enum
|
||||
from qutebrowser.utils.log import downloads as logger
|
||||
from qutebrowser.utils.misc import qt_ensure_valid
|
||||
|
||||
|
||||
@ -78,11 +77,7 @@ class DownloadModel(QAbstractListModel):
|
||||
if index.parent().isValid() or index.column() != 0:
|
||||
return QVariant()
|
||||
|
||||
try:
|
||||
item = self.downloadmanager.downloads[index.row()]
|
||||
except IndexError as e:
|
||||
logger.debug(e)
|
||||
return QVariant()
|
||||
item = self.downloadmanager.downloads[index.row()]
|
||||
if role == Qt.DisplayRole:
|
||||
data = str(item)
|
||||
elif role == Qt.ForegroundRole:
|
||||
|
@ -86,8 +86,8 @@ class QuteSchemeHandler(SchemeHandler):
|
||||
request.url().toDisplayString(), path))
|
||||
try:
|
||||
handler = getattr(QuteHandlers, path)
|
||||
except AttributeError as e:
|
||||
logutils.misc.debug(e)
|
||||
except AttributeError:
|
||||
logutils.misc.warning("No handler found for {}!".format(path))
|
||||
data = bytes()
|
||||
else:
|
||||
data = handler()
|
||||
|
@ -299,7 +299,8 @@ class Question(QObject):
|
||||
# FIXME
|
||||
# We seem to get "pyqtSignal must be bound to a QObject, not
|
||||
# 'Question' here, which makes no sense at all..."
|
||||
logger.debug(e)
|
||||
logger.debug("Error while aborting question: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
|
||||
|
||||
class Timer(QTimer):
|
||||
|
@ -83,7 +83,8 @@ def _git_str():
|
||||
gitpath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
os.path.pardir, os.path.pardir)
|
||||
except NameError as e:
|
||||
logger.debug(e)
|
||||
logger.debug("Error while getting git path: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
else:
|
||||
commit = _git_str_subprocess(gitpath)
|
||||
if commit is not None:
|
||||
@ -126,7 +127,8 @@ def _release_info():
|
||||
with open(fn, 'r') as f:
|
||||
data.append((fn, ''.join(f.readlines())))
|
||||
except IOError as e:
|
||||
logger.warn(e)
|
||||
logger.warn("Error while reading {}: {}: {}".format(
|
||||
fn, e.__class__.__name__, e))
|
||||
return data
|
||||
|
||||
|
||||
@ -147,7 +149,8 @@ def _module_versions():
|
||||
lines.append('SIP: {}'.format(
|
||||
sipconfig.Configuration().sip_version_str))
|
||||
except (AttributeError, TypeError) as e:
|
||||
logger.warn(e)
|
||||
logger.warn("Error while getting SIP version: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
lines.append('SIP: ?')
|
||||
|
||||
try:
|
||||
|
@ -122,7 +122,8 @@ class _CrashDialog(QDialog):
|
||||
self._crash_info.append(("Config",
|
||||
config.instance().dump_userconfig()))
|
||||
except AttributeError as e:
|
||||
self._crash_info.append(("Config", str(e)))
|
||||
self._crash_info.append(("Config", "{}: {}".format(
|
||||
e.__class__.__name__, e)))
|
||||
|
||||
def _format_crash_info(self):
|
||||
"""Format the gathered crash info to be displayed.
|
||||
@ -145,7 +146,8 @@ class _CrashDialog(QDialog):
|
||||
try:
|
||||
url = utils.pastebin(self._txt.toPlainText())
|
||||
except (URLError, ValueError) as e:
|
||||
self._url.setText('Error while reporting: {}'.format(str(e)))
|
||||
self._url.setText('Error while reporting: {}: {}'.format(
|
||||
e.__class__.__name__, e))
|
||||
return
|
||||
self._btn_pastebin.setEnabled(False)
|
||||
self._url.setText("Reported to: <a href='{}'>{}</a>".format(url, url))
|
||||
@ -218,7 +220,8 @@ class ExceptionCrashDialog(_CrashDialog):
|
||||
self._crash_info.append(("Debug log",
|
||||
logutils.ram_handler.dump_log()))
|
||||
except AttributeError as e:
|
||||
self._crash_info.append(("Debug log", str(e)))
|
||||
self._crash_info.append(("Debug log", "{}: {}".format(
|
||||
e.__class__.__name__, e)))
|
||||
|
||||
|
||||
class FatalCrashDialog(_CrashDialog):
|
||||
|
@ -60,15 +60,18 @@ class MainWindow(QWidget):
|
||||
geom = b64decode(stateconf['geometry']['mainwindow'],
|
||||
validate=True)
|
||||
except (KeyError, binascii.Error) as e:
|
||||
logger.warn(e)
|
||||
logger.warn("Error while reading geometry: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
self._set_default_geometry()
|
||||
else:
|
||||
try:
|
||||
ok = self.restoreGeometry(geom)
|
||||
except KeyError:
|
||||
logger.warn(e)
|
||||
logger.warn("Error while restoring geometry: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
self._set_default_geometry()
|
||||
if not ok:
|
||||
logger.warn("Error while restoring geometry.")
|
||||
self._set_default_geometry()
|
||||
|
||||
self._vbox = QVBoxLayout(self)
|
||||
|
@ -135,9 +135,8 @@ class TabbedBrowser(TabWidget):
|
||||
"""
|
||||
try:
|
||||
self._tabs.remove(tab)
|
||||
except ValueError as e:
|
||||
log.destroy.exception("tab {} could not be removed ({})".format(
|
||||
tab, e))
|
||||
except ValueError:
|
||||
log.destroy.exception("tab {} could not be removed")
|
||||
log.destroy.debug("Tabs after removing: {}".format(self._tabs))
|
||||
if not self._tabs: # all tabs shut down
|
||||
log.destroy.debug("Tab shutdown complete.")
|
||||
@ -201,7 +200,8 @@ class TabbedBrowser(TabWidget):
|
||||
try:
|
||||
self.currentChanged.disconnect()
|
||||
except TypeError as e:
|
||||
log.destroy.debug(e)
|
||||
log.destroy.debug("Error while shutting down tabs: {}: {}".format(
|
||||
e.__class__.__name__, e))
|
||||
tabcount = self.count()
|
||||
if tabcount == 0:
|
||||
log.destroy.debug("No tabs -> shutdown complete")
|
||||
|
@ -24,7 +24,6 @@ from PyQt5.QtWidgets import QTabWidget, QTabBar, QSizePolicy
|
||||
from PyQt5.QtGui import QIcon, QPixmap
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
import qutebrowser.utils.log as log
|
||||
from qutebrowser.config.style import set_register_stylesheet
|
||||
from qutebrowser.utils.style import Style
|
||||
|
||||
@ -108,11 +107,8 @@ class TabWidget(QTabWidget):
|
||||
self.setUsesScrollButtons(config.get('tabbar', 'scroll-buttons'))
|
||||
posstr = config.get('tabbar', 'position')
|
||||
selstr = config.get('tabbar', 'select-on-remove')
|
||||
try:
|
||||
self.setTabPosition(position_conv[posstr])
|
||||
self.tabBar().setSelectionBehaviorOnRemove(select_conv[selstr])
|
||||
except KeyError as e:
|
||||
log.init.warn(e)
|
||||
self.setTabPosition(position_conv[posstr])
|
||||
self.tabBar().setSelectionBehaviorOnRemove(select_conv[selstr])
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def on_config_changed(self, section, _option):
|
||||
|
Loading…
Reference in New Issue
Block a user