config: Add a DebugEncryption setting to enable the nio crytpo logs.

This commit is contained in:
Damir Jelić 2019-11-19 16:54:07 +01:00
parent b5ca82976c
commit a51e93a868
3 changed files with 15 additions and 1 deletions

View File

@ -2,6 +2,7 @@
LogLevel = Debug
SSL = True
Notifications = On
DebugEncryption = True
[local-matrix]
Homeserver = https://localhost:8448

View File

@ -38,6 +38,7 @@ class PanConfigParser(configparser.ConfigParser):
"IndexEncryptedOnly": "True",
"IndexingBatchSize": "100",
"HistoryFetchDelay": "3000",
"DebugEncryption": "False",
},
converters={
"address": parse_address,
@ -146,11 +147,14 @@ class PanConfig:
config_path (str): The path where we should search for a configuration
file.
filename (str): The name of the file that we should read.
debug_encryption (bool): Should debug logs be enabled for the Matrix
encryption support.
"""
config_file = attr.ib()
log_level = attr.ib(default=None)
debug_encryption = attr.ib(type=bool, default=None)
notifications = attr.ib(default=None)
servers = attr.ib(init=False, default=attr.Factory(dict))
@ -172,6 +176,8 @@ class PanConfig:
if self.notifications is None:
self.notifications = config["Default"].getboolean("Notifications")
self.debug_encryption = config["Default"].getboolean("DebugEncryption")
listen_set = set()
try:

View File

@ -20,6 +20,8 @@ from typing import Optional
import click
import janus
import keyring
import logbook
import nio
from aiohttp import web
from appdirs import user_config_dir, user_data_dir
from logbook import StderrHandler
@ -127,10 +129,11 @@ async def message_router(receive_queue, send_queue, proxies):
type=click.Choice(["error", "warning", "info", "debug"]),
default=None,
)
@click.option("--debug-encryption", is_flag=True)
@click.option("-c", "--config", type=click.Path(exists=True))
@click.option("--data-path", type=click.Path(exists=True))
@click.pass_context
def main(context, log_level, config, data_path):
def main(context, log_level, debug_encryption, config, data_path):
loop = asyncio.get_event_loop()
conf_dir = user_config_dir("pantalaimon", "")
@ -154,6 +157,10 @@ def main(context, log_level, config, data_path):
context.fail("Homeserver is not configured.")
logger.level = pan_conf.log_level
if pan_conf.debug_encryption or debug_encryption:
nio.crypto.logger.level = logbook.DEBUG
StderrHandler().push_application()
servers = []