Now print exceptions to console when SSH connection is lost

This commit is contained in:
David J. Bianco
2025-01-28 10:21:27 -05:00
parent cea5dc28a2
commit 788bd26845

View File

@ -8,6 +8,7 @@ import threading
import sys import sys
import json import json
import os import os
import traceback
from typing import Optional from typing import Optional
import logging import logging
import datetime import datetime
@ -63,6 +64,7 @@ class MySSHServer(asyncssh.SSHServer):
def connection_lost(self, exc: Optional[Exception]) -> None: def connection_lost(self, exc: Optional[Exception]) -> None:
if exc: if exc:
logger.error('SSH connection error', extra={"error": str(exc)}) logger.error('SSH connection error', extra={"error": str(exc)})
traceback.print_exception(exc)
else: else:
logger.info("SSH connection closed") logger.info("SSH connection closed")
# Ensure session summary is called on connection loss if attributes are set # Ensure session summary is called on connection loss if attributes are set