Skip to content

Conversation

@nycrat
Copy link
Member

@nycrat nycrat commented Dec 7, 2025

Description

Adds --log_level cli arg to full_system that controls the minimum log level from DEBUG, INFO, WARNING, FATAL. If --log_level=WARNING is specified, only WARNING and FATAL messages are logged.

Also adds a --log_level arg to thunderscope which just passes the value specified to full_system when starting.

Testing Done

Added the following code to the unix_full_system_main.cpp main function:

LOG(DEBUG) << "DEBUG";
LOG(INFO) << "INFO";
LOG(WARNING) << "WARNING";
// LOG(FATAL) << "FATAL"; // can't actually log fatal or full_system stops

And ran:

./tbots.py run thunderscope_main --log_level=DEBUG
./tbots.py run thunderscope_main --log_level=INFO
./tbots.py run thunderscope_main --log_level=WARNING
./tbots.py run thunderscope_main --log_level=FATAL

./tbots.py run full_system --log_level=DEBUG
./tbots.py run full_system --log_level=INFO
./tbots.py run full_system --log_level=WARNING
./tbots.py run full_system --log_level=FATAL

And saw that the messages from the expected log levels were printed.

Also tried with adding some log statements to ball_filter.cpp which runs every update, and saw that the behavior is still correct.

Resolved Issues

resolves #1840

Length Justification and Key Files to Review

N/A

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

@nycrat
Copy link
Member Author

nycrat commented Dec 7, 2025

A few things I'm not sure about, firstly, I know we define some custom logging levels that have special behavior like CSV, VISUALIZE, and PLOTJUGGLER. These aren't currently being affected by the minimum log level option, not sure if we want to keep it as such.

Also you'll probably notice the parsing of the log_levels argument in the main function of unix_full_system_main.cpp. From looking at the boost docs, taking in as string and validating using if statements for an enum value seems to be the only way. But maybe I could move to a helper function?

@nycrat nycrat force-pushed the avah/cli_arg_for_g3log_level branch from 76dc9d9 to ccc0b4d Compare December 7, 2025 06:46
@nycrat nycrat force-pushed the avah/cli_arg_for_g3log_level branch from ccc0b4d to 0aa7030 Compare December 7, 2025 06:46
Copy link
Contributor

@StarrryNight StarrryNight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the custom logging options too, but it looks good for me overall!

{
std::cout << "error: --log_level " << args.log_level
<< " is not a valid option." << std::endl;
return 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the argument parsing should be in a separate helper function as it will make the main function less congested.

@nycrat nycrat force-pushed the avah/cli_arg_for_g3log_level branch from 508d471 to 6626987 Compare December 11, 2025 21:54
@nycrat nycrat requested a review from StarrryNight December 11, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an command line arg to full_system to change g3log level

2 participants