summaryrefslogtreecommitdiff
path: root/sshban.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-04-04 13:36:13 +0200
committerAnton Khirnov <anton@khirnov.net>2020-04-04 13:36:13 +0200
commit233815932553bdf9781e6bbde9976abfe458b93a (patch)
tree66dedfc9b636b519dff615d5a444d10f869fc96f /sshban.py
parent6ad84a587e6177b7c8af101b4806a1fc5f8c082b (diff)
sshban: log uncaught top-level exception
Makes it more noticeable when sshban dies.
Diffstat (limited to 'sshban.py')
-rwxr-xr-xsshban.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/sshban.py b/sshban.py
index 0479764..dd2a5f2 100755
--- a/sshban.py
+++ b/sshban.py
@@ -177,6 +177,11 @@ for h in handlers:
h.setFormatter(formatter)
logger.addHandler(h)
+# log uncaught top-level exception
+def excepthook(t, v, tb, logger = logger):
+ logger.error('Uncaught top-level exception', exc_info = (t, v, tb))
+sys.excepthook = excepthook
+
judge = Judge({ ACT_BAN_SHORT : args.thresh_short, ACT_BAN_MEDIUM : args.thresh_medium, ACT_BAN_LONG : args.thresh_long })
# open FIFO read-write so poll() won't return HUP endlessly if the writer dies