Skip to content

Conversation

john-michaelburke
Copy link
Collaborator

  • Expose cli argument for logging additionally to standard error. cargo make run -- --log-to-std
  • Converted all "relevant to user" usage of eprintln/println to appropriate debug/error etc..
  • Also changed timestamp format to match that of the old console.

pub fn from_filtered_cli() -> CliOptions {
let args = std::env::args();
debug!("args {:?}", args);
eprintln!("args {:?}", args);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seemed overkill to have this and filtered args display in the console log so this only goes to standard error.

filtered_args.push(arg);
}
debug!("filtered_args: {:?}", filtered_args);
debug!("filtered_args: {:?}", &filtered_args[1..]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove the first argument which equates to the python3 to only show arguments passed to console.

}
} else {
eprintln!("no client receive endpoint");
debug!("no client receive endpoint");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not entirely sure what to do here. These debug statements never show, I think there is an issue with logging from within a PyObject. Either we keep them as eprintln or remove them entirely. What are your thoughts @silverjam?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try with the headless console and see if they show? That's using env_logger not our custom logger.

Copy link
Collaborator Author

@john-michaelburke john-michaelburke Oct 19, 2021

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking of the fileio module: https://github.com/swift-nav/console_pp/blob/f8366907c72f55ce5c6d1b40e23d255d09afaf5c/console_backend/src/bin/fileio.rs#L51 -- might try enabling that here too and see what happens

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@silverjam Looking at this again, no we cannot try this in headless console because these messages are in server.rs. These two functions fetch_message and start are the only things we do not run in headless-console. The headless-console is more or less a duplicate of start but tailored for lifetime testing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could abstract these functions outside of server.rs and call them from the external location. The headless runner would still need to be separate though to add the message counting. Maybe in a separate PR.

Copy link
Contributor

@silverjam silverjam Oct 26, 2021

Choose a reason for hiding this comment

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

I'm fine with pushing fix-ups to another PR, but I was suggesting just throwing in a call to env_logger::init(); to see if it caught the log messages we're missing. If it does then it means we'll need to rework how we're setting up our custom log destination so that it happens earlier.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's put these back to eprintln! for now -- see https://pyo3.rs/v0.12.4/logging.html -- they log through the Python logging system, but the logger is setup during module initialization

reset_device: false,
advanced_networking_update: None,
auto_survey_data: AutoSurveyData::new(),
log_to_std: ArcBool::new_with(true),
Copy link
Collaborator Author

@john-michaelburke john-michaelburke Oct 19, 2021

Choose a reason for hiding this comment

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

Start with true so the initial "args" will go to the terminal. Then once the command line options are parsed, if log-to-std is not enabled it will switch back to false.
Screen Shot 2021-10-19 at 11 26 44 AM
.

@john-michaelburke john-michaelburke marked this pull request as ready for review October 19, 2021 18:30
@john-michaelburke john-michaelburke requested a review from a team October 19, 2021 18:30
@john-michaelburke john-michaelburke force-pushed the john-michaelburke/debug-cli branch from 1736b7c to ce1b1d0 Compare October 26, 2021 20:27
Copy link
Contributor

@silverjam silverjam left a comment

Choose a reason for hiding this comment

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

Currently solution is an improvement but we need to move logging around so that it happens earlier and (maybe) re-work logging so that it happens via Python logging module: https://pyo3.rs/v0.12.4/logging.html -- @john-michaelburke can you log a Jira for this please?

}
} else {
eprintln!("no client receive endpoint");
debug!("no client receive endpoint");
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's put these back to eprintln! for now -- see https://pyo3.rs/v0.12.4/logging.html -- they log through the Python logging system, but the logger is setup during module initialization

@john-michaelburke
Copy link
Collaborator Author

Currently solution is an improvement but we need to move logging around so that it happens earlier and (maybe) re-work logging so that it happens via Python logging module: https://pyo3.rs/v0.12.4/logging.html -- @john-michaelburke can you log a Jira for this please?

Done. https://swift-nav.atlassian.net/browse/CPP-376

@john-michaelburke john-michaelburke merged commit f957fa9 into main Oct 26, 2021
@john-michaelburke john-michaelburke deleted the john-michaelburke/debug-cli branch October 26, 2021 21:53
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.

3 participants