summaryrefslogtreecommitdiff
path: root/python/vyos/airbag.py
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-04-20 16:07:59 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-04-20 16:07:59 +0100
commitb704d0676ab2d623d2eeb1ed4dc1bcf2a2c4a5e2 (patch)
tree6d5232d15befa14e77ee7e82f839cdff95867ec9 /python/vyos/airbag.py
parent6b8a6619533c7f47a63e041efb516ad91b10b4da (diff)
downloadvyos-1x-b704d0676ab2d623d2eeb1ed4dc1bcf2a2c4a5e2.tar.gz
vyos-1x-b704d0676ab2d623d2eeb1ed4dc1bcf2a2c4a5e2.zip
airbag: T2186: generic syslog
Diffstat (limited to 'python/vyos/airbag.py')
-rw-r--r--python/vyos/airbag.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/python/vyos/airbag.py b/python/vyos/airbag.py
index b0565192d..a2e9de491 100644
--- a/python/vyos/airbag.py
+++ b/python/vyos/airbag.py
@@ -15,15 +15,13 @@
import os
import sys
-import logging
-import logging.handlers
from datetime import datetime
from vyos import debug
from vyos.config import Config
from vyos.version import get_version
from vyos.util import run
-
+from vyos.logger import syslog
# we allow to disable the extra logging
DISABLE = False
@@ -62,7 +60,7 @@ def bug_report(dtype, value, trace):
information = {
'date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'version': get_version(),
- 'trace': format_exception(dtype, value, trace),
+ 'trace': '\n'.join(format_exception(dtype, value, trace)),
'instructions': COMMUNITY if 'rolling' in get_version() else SUPPORTED,
}
@@ -82,19 +80,14 @@ def intercepter(dtype, value, trace):
pdb.pm()
-def InterceptingLogger(address, _singleton=[False]):
+def InterceptingLogger(_singleton=[False]):
skip = _singleton.pop()
_singleton.append(True)
if skip:
return
- logger = logging.getLogger('VyOS')
- logger.setLevel(logging.DEBUG)
- handler = logging.handlers.SysLogHandler(address='/dev/log', facility='syslog')
- logger.addHandler(handler)
-
# log to syslog any message sent to stderr
- sys.stderr = _IO(sys.stderr, logger.critical)
+ sys.stderr = _IO(sys.stderr, syslog.critical)
# lists as default arguments in function is normally dangerous
@@ -124,14 +117,15 @@ except:
# running testing so we are checking that we are on the router
# as otherwise it prevents dpkg-buildpackage to work
if get_version() and insession:
- InterceptingLogger('/run/systemd/journal/dev-log')
+ InterceptingLogger()
InterceptingException(intercepter)
# Messages to print
+# if the key before the value has not time, syslog takes that as the source of the message
FAULT = """\
-Date: {date}
+Fault Time: {date}
VyOS image: {version}
{trace}