summaryrefslogtreecommitdiff
path: root/fail2ban/helpers.py
diff options
context:
space:
mode:
authorLee Clemens <java@leeclemens.net>2015-07-04 13:47:40 -0400
committerLee Clemens <java@leeclemens.net>2015-07-04 13:47:40 -0400
commitfdc3172aece85956c0269f889ecf3e9d0db8b49a (patch)
tree8d09afe81479333e22554002af52f879dba037f9 /fail2ban/helpers.py
parentfbeee8bb28246685525b23a5a694109eadc6a57b (diff)
downloadfail2ban-fdc3172aece85956c0269f889ecf3e9d0db8b49a.tar.gz
Fix PEP8 E302 expected 2 blank lines, found X
Diffstat (limited to 'fail2ban/helpers.py')
-rw-r--r--fail2ban/helpers.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/fail2ban/helpers.py b/fail2ban/helpers.py
index cecd3f31..f5c3163a 100644
--- a/fail2ban/helpers.py
+++ b/fail2ban/helpers.py
@@ -26,11 +26,13 @@ import traceback
import re
import logging
+
def formatExceptionInfo():
""" Consistently format exception information """
cla, exc = sys.exc_info()[:2]
return (cla.__name__, str(exc))
+
#
# Following "traceback" functions are adopted from PyMVPA distributed
# under MIT/Expat and copyright by PyMVPA developers (i.e. me and
@@ -49,6 +51,7 @@ def mbasename(s):
base = os.path.basename(os.path.dirname(s)) + '.' + base
return base
+
class TraceBack(object):
"""Customized traceback to be included in debug messages
"""
@@ -94,6 +97,7 @@ class TraceBack(object):
return sftb
+
class FormatterWithTraceBack(logging.Formatter):
"""Custom formatter which expands %(tb) and %(tbc) with tracebacks
@@ -108,6 +112,7 @@ class FormatterWithTraceBack(logging.Formatter):
record.tbc = record.tb = self._tb()
return logging.Formatter.format(self, record)
+
def getLogger(name):
"""Get logging.Logger instance with Fail2Ban logger name convention
"""
@@ -115,6 +120,7 @@ def getLogger(name):
name = "fail2ban.%s" % name.rpartition(".")[-1]
return logging.getLogger(name)
+
def excepthook(exctype, value, traceback):
"""Except hook used to log unhandled exceptions to Fail2Ban log
"""