summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/commands.rst6
-rw-r--r--poezio/config.py2
-rw-r--r--poezio/core/command_defs.py7
-rw-r--r--poezio/core/commands.py14
4 files changed, 25 insertions, 4 deletions
diff --git a/doc/source/commands.rst b/doc/source/commands.rst
index 2a179b8d..d1763084 100644
--- a/doc/source/commands.rst
+++ b/doc/source/commands.rst
@@ -34,6 +34,12 @@ These commands work in *any* tab.
available commands. If it has a valid command as an argument, this command
will show the usage and the help for the given command.
+ /debug
+ **Usage:** ``/debug [filename]
+
+ Reset logging and enable debugging to ``[filename]``. If the filename
+ is empty, debug logging will be disabled.
+
/join
**Usage:** ``/join [room_name][@server][/nick] [password]``
diff --git a/poezio/config.py b/poezio/config.py
index 102c5dd0..5ea88a76 100644
--- a/poezio/config.py
+++ b/poezio/config.py
@@ -679,7 +679,7 @@ def post_logging_setup():
LOGGING_CONFIG = {
'version': 1,
- 'disable_existing_loggers': True,
+ 'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '%(asctime)s %(levelname)s:%(module)s:%(message)s'
diff --git a/poezio/core/command_defs.py b/poezio/core/command_defs.py
index 28bb053c..770b3492 100644
--- a/poezio/core/command_defs.py
+++ b/poezio/core/command_defs.py
@@ -442,4 +442,11 @@ def get_commands(commands: CommandCore, completions: CompletionCore, plugin_mana
"shortdesc": "Reload the config. You can achieve the same by "
"sending SIGUSR1 to poezio.",
},
+ {
+ "name": "debug",
+ "func": commands.debug,
+ "usage": "[debug_filename]",
+ "shortdesc": "Enable or disable debug logging according to the "
+ "presence of [debug_filename].",
+ },
]
diff --git a/poezio/core/commands.py b/poezio/core/commands.py
index 75f90279..85aa76e8 100644
--- a/poezio/core/commands.py
+++ b/poezio/core/commands.py
@@ -14,9 +14,7 @@ from slixmpp.xmlstream.stanzabase import StanzaBase
from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath
-from poezio import common
-from poezio import tabs
-from poezio import multiuserchat as muc
+from poezio import common, config as config_module, tabs, multiuserchat as muc
from poezio.bookmarks import Bookmark
from poezio.config import config, DEFAULT_CONFIG
from poezio.contact import Contact, Resource
@@ -1356,6 +1354,16 @@ class CommandCore:
"""
self.core.reload_config()
+ @command_args_parser.raw
+ def debug(self, args):
+ """/debug [filename]"""
+ if not args.strip():
+ config_module.setup_logging('')
+ self.core.information('Debug logging disabled!', 'Info')
+ elif args:
+ config_module.setup_logging(args)
+ self.core.information(f'Debug logging to {args} enabled!', 'Info')
+
def dumb_callback(*args, **kwargs):
"mock callback"