ros2 component uses --log-level to specify the log severity level, whereas ros2 log watch uses --level.
Modify ros2log/ros2log/verb/watch.py to accept --log-level as an alias for --level:
ros2log/ros2log/verb/watch.py
Example: How to add the alias
Keep '--level' first (so args.level continues to work without changing the rest of the file) and add '--log-level':
# Before:
parser.add_argument(
'--level',
choices=['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL',
'debug', 'info', 'warn', 'error', 'fatal'],
help='Show only logs at or above the specified severity level')
# After:
parser.add_argument(
'--level', '--log-level',
choices=['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL',
'debug', 'info', 'warn', 'error', 'fatal'],
help='Show only logs at or above the specified severity level')
Example: How to add a test
Add a test in ros2log/test/test_watch.py to verify that --log-level populates args.level:
import argparse
from ros2log.verb.watch import WatchVerb
def test_watch_log_level_alias():
parser = argparse.ArgumentParser()
verb = WatchVerb()
verb.add_arguments(parser, 'ros2 log watch')
args = parser.parse_args(['--log-level', 'WARN'])
assert args.level == 'WARN'
ros2 componentuses--log-levelto specify the log severity level, whereasros2 log watchuses--level.Modify
ros2log/ros2log/verb/watch.pyto accept--log-levelas an alias for--level:ros2log/ros2log/verb/watch.pyExample: How to add the alias
Keep
'--level'first (soargs.levelcontinues to work without changing the rest of the file) and add'--log-level':Example: How to add a test
Add a test in
ros2log/test/test_watch.pyto verify that--log-levelpopulatesargs.level: