Remove PosixPath() in logs and add proper exception logging
This commit is contained in:
parent
1e6655a715
commit
2bf809c454
@ -321,8 +321,8 @@ async def start_session() -> None:
|
||||
except ClientError as c:
|
||||
write(err("Something went wrong"))
|
||||
logger.error(f"Unexpected client error: {c}")
|
||||
except Exception as e:
|
||||
logger.error(f"Serious client error: {e}")
|
||||
except:
|
||||
logger.exception("Serious client error")
|
||||
raise
|
||||
finally:
|
||||
with contextlib.suppress(KeyError):
|
||||
@ -371,7 +371,7 @@ async def create_pop_server(
|
||||
timeout_seconds: int = 60,
|
||||
) -> asyncio.Server:
|
||||
logging.info(
|
||||
f"Starting POP3 server {host=}, {port=}, {mails_path=}, {len(users)=}, {ssl_context != None=}, {timeout_seconds=}"
|
||||
f"Starting POP3 server {host=}, {port=}, {mails_path=!s}, {len(users)=}, {ssl_context != None=}, {timeout_seconds=}"
|
||||
)
|
||||
return await asyncio.start_server(
|
||||
make_pop_server_callback(mails_path, users, timeout_seconds),
|
||||
|
@ -150,7 +150,7 @@ def main() -> None:
|
||||
else:
|
||||
cfg = config.Config(args.config.read_text())
|
||||
setup_logging(config.LogCfg(cfg.logging))
|
||||
logging.info(f"Starting mail4one {args.config=}")
|
||||
logging.info(f"Starting mail4one {args.config=!s}")
|
||||
asyncio.run(a_main(cfg))
|
||||
|
||||
|
||||
|
@ -75,8 +75,8 @@ def protocol_factory_starttls(mails_path: Path,
|
||||
tls_context=context,
|
||||
enable_SMTPUTF8=True,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error("Something went wrong", e)
|
||||
except:
|
||||
logger.exception("Something went wrong")
|
||||
raise
|
||||
return smtp
|
||||
|
||||
@ -87,8 +87,8 @@ def protocol_factory(mails_path: Path, mbox_finder: Callable[[str],
|
||||
try:
|
||||
handler = MyHandler(mails_path, mbox_finder)
|
||||
smtp = SMTP(handler=handler, enable_SMTPUTF8=True)
|
||||
except Exception as e:
|
||||
logger.error("Something went wrong", e)
|
||||
except:
|
||||
logger.exception("Something went wrong")
|
||||
raise
|
||||
return smtp
|
||||
|
||||
@ -101,7 +101,7 @@ async def create_smtp_server_starttls(
|
||||
ssl_context: ssl.SSLContext,
|
||||
) -> asyncio.Server:
|
||||
logging.info(
|
||||
f"Starting SMTP STARTTLS server {host=}, {port=}, {mails_path=}, {ssl_context != None=}"
|
||||
f"Starting SMTP STARTTLS server {host=}, {port=}, {mails_path=!s}, {ssl_context != None=}"
|
||||
)
|
||||
loop = asyncio.get_event_loop()
|
||||
return await loop.create_server(
|
||||
@ -121,7 +121,7 @@ async def create_smtp_server(
|
||||
ssl_context: ssl.SSLContext | None = None,
|
||||
) -> asyncio.Server:
|
||||
logging.info(
|
||||
f"Starting SMTP server {host=}, {port=}, {mails_path=}, {ssl_context != None=}"
|
||||
f"Starting SMTP server {host=}, {port=}, {mails_path=!s}, {ssl_context != None=}"
|
||||
)
|
||||
loop = asyncio.get_event_loop()
|
||||
return await loop.create_server(
|
||||
|
Loading…
Reference in New Issue
Block a user