diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-06 16:34:24 +0100 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-08 15:00:29 +0100 |
commit | f35a14e76c0b510cc9b7d41c9cc4e9fed3bb8457 (patch) | |
tree | c9e154017dbcebb8f9249a855547e2f2277663c0 /python/vyos/util.py | |
parent | 495012f7737302f458ff60fe2a93d0972cd3443d (diff) | |
download | vyos-1x-f35a14e76c0b510cc9b7d41c9cc4e9fed3bb8457.tar.gz vyos-1x-f35a14e76c0b510cc9b7d41c9cc4e9fed3bb8457.zip |
logging: T2186: Initial implementation of logging
All messages sent to stderr are now logged to syslog.
Also should a raise statement not be handled by the program,
a friendlier message is sent to the user (with the trace to
syslog)
It provide a new debug option: /tmp/vyos.developer.debug
when the file exists and the code raise without being caught up
the program will automatically fall into pdb port-morterm mode
allowing to investigate the reason for the failure
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r-- | python/vyos/util.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index 16cfae92d..e61de52bd 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -19,6 +19,12 @@ import sys from subprocess import Popen, PIPE, STDOUT, DEVNULL def debug(flag): + # this is to force all new flags to be registered here so that + # they can be documented: + # - developer: the code will drop into PBD on un-handled exception + # - ifconfig: prints command and sysfs access on stdout for interface + if flag not in ['developer', 'ifconfig']: + return False return flag if os.path.isfile(f'/tmp/vyos.{flag}.debug') else '' |