Clean up loggers.
This commit is contained in:
parent
f85ba8645f
commit
c071bcbec8
@ -356,7 +356,7 @@ class ConfigManager(QObject):
|
||||
try:
|
||||
desc = self.sections[sectname].descriptions[optname]
|
||||
except KeyError:
|
||||
log.misc.exception("No description for {}.{}!".format(
|
||||
log.config.exception("No description for {}.{}!".format(
|
||||
sectname, optname))
|
||||
continue
|
||||
for descline in desc.splitlines():
|
||||
@ -473,7 +473,7 @@ class ConfigManager(QObject):
|
||||
|
||||
def _changed(self, sectname, optname):
|
||||
"""Notify other objects the config has changed."""
|
||||
log.misc.debug("Config option changed: {} -> {}".format(
|
||||
log.config.debug("Config option changed: {} -> {}".format(
|
||||
sectname, optname))
|
||||
if sectname in ('colors', 'fonts'):
|
||||
self.style_changed.emit(sectname, optname)
|
||||
|
@ -56,7 +56,7 @@ def set_register_stylesheet(obj):
|
||||
Must have a STYLESHEET attribute.
|
||||
"""
|
||||
qss = get_stylesheet(obj.STYLESHEET)
|
||||
log.style.vdebug("stylesheet for {}: {}".format(
|
||||
log.config.vdebug("stylesheet for {}: {}".format(
|
||||
obj.__class__.__name__, qss))
|
||||
obj.setStyleSheet(qss)
|
||||
objreg.get('config').changed.connect(
|
||||
@ -91,7 +91,7 @@ class ColorDict(dict):
|
||||
try:
|
||||
val = super().__getitem__(key)
|
||||
except KeyError:
|
||||
log.style.exception("No color defined for {}!")
|
||||
log.config.exception("No color defined for {}!")
|
||||
return ''
|
||||
if isinstance(val, QColor):
|
||||
# This could happen when accidentally declaring something as
|
||||
|
@ -84,7 +84,7 @@ class Base:
|
||||
qws: The QWebSettings instance to use, or None to use the global
|
||||
instance.
|
||||
"""
|
||||
log.misc.vdebug("Restoring default {!r}.".format(self._default))
|
||||
log.config.vdebug("Restoring default {!r}.".format(self._default))
|
||||
if self._default is not UNSET:
|
||||
self._set(self._default, qws=qws)
|
||||
|
||||
@ -383,10 +383,10 @@ def init():
|
||||
for sectname, section in MAPPINGS.items():
|
||||
for optname, mapping in section.items():
|
||||
default = mapping.save_default()
|
||||
log.misc.vdebug("Saved default for {} -> {}: {!r}".format(
|
||||
log.config.vdebug("Saved default for {} -> {}: {!r}".format(
|
||||
sectname, optname, default))
|
||||
value = config.get(sectname, optname)
|
||||
log.misc.vdebug("Setting {} -> {} to {!r}".format(
|
||||
log.config.vdebug("Setting {} -> {} to {!r}".format(
|
||||
sectname, optname, value))
|
||||
mapping.set(value)
|
||||
objreg.get('config').changed.connect(update_settings)
|
||||
|
@ -71,10 +71,10 @@ class Text(textbase.TextBase):
|
||||
def maybe_reset_text(self, text):
|
||||
"""Clear a normal text if it still matches an expected text."""
|
||||
if self._normaltext == text:
|
||||
log.misc.debug("Resetting: '{}'".format(text))
|
||||
log.statusbar.debug("Resetting: '{}'".format(text))
|
||||
self.set_text(self.Text.normal, '')
|
||||
else:
|
||||
log.misc.debug("Ignoring reset: '{}'".format(text))
|
||||
log.statusbar.debug("Ignoring reset: '{}'".format(text))
|
||||
|
||||
@config.change_filter('ui', 'display-statusbar-messages')
|
||||
def update_text(self):
|
||||
|
@ -195,13 +195,13 @@ class SessionManager(QObject):
|
||||
name = 'default'
|
||||
path = self._get_session_path(name)
|
||||
|
||||
log.misc.debug("Saving session {} to {}...".format(name, path))
|
||||
log.sessions.debug("Saving session {} to {}...".format(name, path))
|
||||
if last_window:
|
||||
data = self._last_window_session
|
||||
assert data is not None
|
||||
else:
|
||||
data = self._save_all()
|
||||
log.misc.vdebug("Saving data: {}".format(data))
|
||||
log.sessions.vdebug("Saving data: {}".format(data))
|
||||
try:
|
||||
with qtutils.savefile_open(path) as f:
|
||||
yaml.dump(data, f, Dumper=YamlDumper, default_flow_style=False,
|
||||
@ -260,7 +260,7 @@ class SessionManager(QObject):
|
||||
data = yaml.load(f, Loader=YamlLoader)
|
||||
except (OSError, UnicodeDecodeError, yaml.YAMLError) as e:
|
||||
raise SessionError(e)
|
||||
log.misc.debug("Loading session {} from {}...".format(name, path))
|
||||
log.sessions.debug("Loading session {} from {}...".format(name, path))
|
||||
for win in data['windows']:
|
||||
window = mainwindow.MainWindow(geometry=win['geometry'])
|
||||
window.show()
|
||||
@ -376,9 +376,9 @@ class SessionManager(QObject):
|
||||
try:
|
||||
self.delete(name)
|
||||
except SessionNotFoundError as e:
|
||||
log.misc.exception("Session not found!")
|
||||
log.sessions.exception("Session not found!")
|
||||
raise cmdexc.CommandError("Session {} not found".format(e))
|
||||
except (OSError, SessionError) as e:
|
||||
log.misc.exception("Error while deleting session!")
|
||||
log.sessions.exception("Error while deleting session!")
|
||||
raise cmdexc.CommandError("Error while deleting session: {}"
|
||||
.format(e))
|
||||
|
@ -57,7 +57,7 @@ def log_signals(obj):
|
||||
r = repr(obj)
|
||||
except RuntimeError:
|
||||
r = '<deleted>'
|
||||
log.misc.debug("Signal in {}: {}".format(r, dbg))
|
||||
log.signals.debug("Signal in {}: {}".format(r, dbg))
|
||||
|
||||
def connect_log_slot(obj):
|
||||
"""Helper function to connect all signals to a logging slot."""
|
||||
|
@ -122,11 +122,12 @@ keyboard = logging.getLogger('keyboard')
|
||||
downloads = logging.getLogger('downloads')
|
||||
js = logging.getLogger('js') # Javascript console messages
|
||||
qt = logging.getLogger('qt') # Warnings produced by Qt
|
||||
style = logging.getLogger('style')
|
||||
rfc6266 = logging.getLogger('rfc6266')
|
||||
ipc = logging.getLogger('ipc')
|
||||
shlexer = logging.getLogger('shlexer')
|
||||
save = logging.getLogger('save')
|
||||
message = logging.getLogger('message')
|
||||
config = logging.getLogger('config')
|
||||
|
||||
|
||||
ram_handler = None
|
||||
|
@ -52,7 +52,7 @@ def _wrapper(win_id, method_name, text, *args, **kwargs):
|
||||
bridge = _get_bridge(win_id)
|
||||
except objreg.RegistryUnavailableError:
|
||||
if win_id == 'current':
|
||||
log.misc.debug("Queueing {} for current window".format(
|
||||
log.message.debug("Queueing {} for current window".format(
|
||||
method_name))
|
||||
_QUEUED.append(msg)
|
||||
else:
|
||||
@ -68,8 +68,8 @@ def _wrapper(win_id, method_name, text, *args, **kwargs):
|
||||
window_focused):
|
||||
getattr(bridge, method_name)(text, *args, **kwargs)
|
||||
else:
|
||||
log.misc.debug("Queueing {} for window {}".format(method_name,
|
||||
win_id))
|
||||
log.message.debug("Queueing {} for window {}".format(
|
||||
method_name, win_id))
|
||||
_QUEUED.append(msg)
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ def on_focus_changed():
|
||||
while _QUEUED:
|
||||
msg = _QUEUED.pop()
|
||||
delta = datetime.datetime.now() - msg.time
|
||||
log.misc.debug("Handling queued {} for window {}, delta {}".format(
|
||||
log.message.debug("Handling queued {} for window {}, delta {}".format(
|
||||
msg.method_name, msg.win_id, delta))
|
||||
try:
|
||||
bridge = _get_bridge(msg.win_id)
|
||||
@ -274,7 +274,7 @@ class MessageBridge(QObject):
|
||||
messages should be queued.
|
||||
"""
|
||||
msg = str(msg)
|
||||
log.misc.error(msg)
|
||||
log.message.error(msg)
|
||||
self.s_error.emit(msg, immediately)
|
||||
|
||||
def warning(self, msg, immediately=False):
|
||||
@ -289,7 +289,7 @@ class MessageBridge(QObject):
|
||||
messages should be queued.
|
||||
"""
|
||||
msg = str(msg)
|
||||
log.misc.warning(msg)
|
||||
log.message.warning(msg)
|
||||
self.s_warning.emit(msg, immediately)
|
||||
|
||||
def info(self, msg, immediately=True):
|
||||
@ -300,7 +300,7 @@ class MessageBridge(QObject):
|
||||
do rarely happen without user interaction.
|
||||
"""
|
||||
msg = str(msg)
|
||||
log.misc.info(msg)
|
||||
log.message.info(msg)
|
||||
self.s_info.emit(msg, immediately)
|
||||
|
||||
def set_cmd_text(self, text):
|
||||
@ -310,7 +310,7 @@ class MessageBridge(QObject):
|
||||
text: The text to set.
|
||||
"""
|
||||
text = str(text)
|
||||
log.misc.debug(text)
|
||||
log.message.debug(text)
|
||||
self.s_set_cmd_text.emit(text)
|
||||
|
||||
def set_text(self, text):
|
||||
@ -320,7 +320,7 @@ class MessageBridge(QObject):
|
||||
text: The text to set.
|
||||
"""
|
||||
text = str(text)
|
||||
log.misc.debug(text)
|
||||
log.message.debug(text)
|
||||
self.s_set_text.emit(text)
|
||||
|
||||
def maybe_reset_text(self, text):
|
||||
|
@ -115,12 +115,12 @@ class ObjectRegistry(collections.UserDict):
|
||||
be destroying its children, which might still use the object
|
||||
registry.
|
||||
"""
|
||||
log.misc.debug("schedule removal: {}".format(name))
|
||||
log.destroy.debug("schedule removal: {}".format(name))
|
||||
QTimer.singleShot(0, functools.partial(self._on_destroyed, name))
|
||||
|
||||
def _on_destroyed(self, name):
|
||||
"""Remove a destroyed QObject."""
|
||||
log.misc.debug("removed: {}".format(name))
|
||||
log.destroy.debug("removed: {}".format(name))
|
||||
try:
|
||||
del self[name]
|
||||
del self._partial_objs[name]
|
||||
|
@ -146,4 +146,4 @@ def init(args):
|
||||
f.write("# For information about cache directory tags, see:\n")
|
||||
f.write("# http://www.brynosaurus.com/cachedir/\n")
|
||||
except OSError:
|
||||
log.misc.exception("Failed to create CACHEDIR.TAG")
|
||||
log.init.exception("Failed to create CACHEDIR.TAG")
|
||||
|
@ -120,7 +120,7 @@ def actute_warning():
|
||||
"for details.")
|
||||
break
|
||||
except OSError:
|
||||
log.misc.exception("Failed to read Compose file")
|
||||
log.init.exception("Failed to read Compose file")
|
||||
|
||||
|
||||
def _get_color_percentage(a_c1, a_c2, a_c3, b_c1, b_c2, b_c3, percent):
|
||||
|
Loading…
Reference in New Issue
Block a user