summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDuncan Eastoe <duncan.eastoe@att.com>2020-07-14 19:03:56 +0200
committerDuncan Eastoe <duncan.eastoe@att.com>2020-07-14 20:05:17 +0200
commit9c782ad2a4e5106d25946a07adf97805302faf38 (patch)
tree56dea1bb44e4bf9a29bd339af7dfc200a2479639 /tools
parentMerge pull request #6721 from kuldeepkash/bgp_basic_functionality (diff)
downloadfrr-9c782ad2a4e5106d25946a07adf97805302faf38.tar.xz
frr-9c782ad2a4e5106d25946a07adf97805302faf38.zip
tools: frr-reload: more detailed log level control
Add a "--log-level" option to frr-reload to set the maximum message level to be logged. When the option is not used, the level is set to info as before. The existing --debug option is synonymous with --log-level=debug and these options are therefore mutually exclusive. Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/frr-reload.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index 9e86cf215..772a9bc88 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -1169,7 +1169,11 @@ if __name__ == '__main__':
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--reload', action='store_true', help='Apply the deltas', default=False)
group.add_argument('--test', action='store_true', help='Show the deltas', default=False)
- parser.add_argument('--debug', action='store_true', help='Enable debugs', default=False)
+ level_group = parser.add_mutually_exclusive_group()
+ level_group.add_argument('--debug', action='store_true',
+ help='Enable debugs (synonym for --log-level=debug)', default=False)
+ level_group.add_argument('--log-level', help='Log level', default="info",
+ choices=("critical", "error", "warning", "info", "debug"))
parser.add_argument('--stdout', action='store_true', help='Log to STDOUT', default=False)
parser.add_argument('filename', help='Location of new frr config file')
parser.add_argument('--overwrite', action='store_true', help='Overwrite frr.conf with running config output', default=False)
@@ -1185,8 +1189,7 @@ if __name__ == '__main__':
# For --test log to stdout
# For --reload log to /var/log/frr/frr-reload.log
if args.test or args.stdout:
- logging.basicConfig(level=logging.INFO,
- format='%(asctime)s %(levelname)5s: %(message)s')
+ logging.basicConfig(format='%(asctime)s %(levelname)5s: %(message)s')
# Color the errors and warnings in red
logging.addLevelName(logging.ERROR, "\033[91m %s\033[0m" % logging.getLevelName(logging.ERROR))
@@ -1197,7 +1200,6 @@ if __name__ == '__main__':
os.makedirs('/var/log/frr/')
logging.basicConfig(filename='/var/log/frr/frr-reload.log',
- level=logging.INFO,
format='%(asctime)s %(levelname)5s: %(message)s')
# argparse should prevent this from happening but just to be safe...
@@ -1205,6 +1207,11 @@ if __name__ == '__main__':
raise Exception('Must specify --reload or --test')
log = logging.getLogger(__name__)
+ if args.debug:
+ log.setLevel(logging.DEBUG)
+ else:
+ log.setLevel(args.log_level.upper())
+
# Verify the new config file is valid
if not os.path.isfile(args.filename):
msg = "Filename %s does not exist" % args.filename
@@ -1267,9 +1274,6 @@ if __name__ == '__main__':
log.error(msg)
sys.exit(1)
- if args.debug:
- log.setLevel(logging.DEBUG)
-
log.info('Called via "%s"', str(args))
# Create a Config object from the config generated by newconf