-
Notifications
You must be signed in to change notification settings - Fork 2
Expose log-to-std, fix log timestamp.[CPP-109] #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ce1b1d0
Expose log-to-std, fix log timestamp.[CPP-109]
john-michaelburke 9433f3d
Update console_backend/src/cli_options.rs
john-michaelburke d220e32
Update console_backend/src/cli_options.rs
john-michaelburke 3c904dd
Additional change to use log-stderr.
john-michaelburke 3c16fea
Revert server.rs debug calls to eprintln.
john-michaelburke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,10 @@ pub struct CliOptions { | |
#[clap(subcommand)] | ||
pub input: Option<Input>, | ||
|
||
/// Log messages to terminal. | ||
#[clap(long = "log-stderr")] | ||
pub log_stderr: bool, | ||
|
||
/// Exit when connection closes. | ||
#[clap(long = "exit-after")] | ||
pub exit_after: bool, | ||
|
@@ -150,7 +154,7 @@ impl CliOptions { | |
/// - `filtered_args`: The filtered args parsed via CliOptions. | ||
pub fn from_filtered_cli() -> CliOptions { | ||
let args = std::env::args(); | ||
debug!("args {:?}", args); | ||
eprintln!("args {:?}", args); | ||
let mut next_args = std::env::args().skip(1); | ||
let mut filtered_args: Vec<String> = vec![]; | ||
for arg in args.filter(|a| !matches!(a.as_str(), "swiftnav_console.main" | "-m" | "--")) { | ||
|
@@ -168,7 +172,7 @@ impl CliOptions { | |
} | ||
filtered_args.push(arg); | ||
} | ||
debug!("filtered_args: {:?}", filtered_args); | ||
debug!("filtered_args: {:?}", &filtered_args[1..]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the first argument which equates to the |
||
CliOptions::parse_from(filtered_args) | ||
} | ||
} | ||
|
@@ -306,6 +310,7 @@ pub fn handle_cli(opt: CliOptions, conn_manager: &ConnectionManager, shared_stat | |
shared_state.set_log_level(log_level); | ||
let mut shared_data = shared_state.lock().expect(SHARED_STATE_LOCK_MUTEX_FAILURE); | ||
(*shared_data).logging_bar.csv_logging = CsvLogging::from(opt.csv_log); | ||
(*shared_data).log_to_std.set(opt.log_stderr); | ||
if let Some(sbp_log) = opt.sbp_log { | ||
(*shared_data).logging_bar.sbp_logging_format = | ||
SbpLogging::from_str(&sbp_log.to_string()).expect(CONVERT_TO_STR_FAILURE); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ use crate::output::{CsvLogging, CsvSerializer}; | |
use crate::process_messages::StopToken; | ||
use crate::settings_tab; | ||
use crate::solution_tab::LatLonUnits; | ||
use crate::types::CapnProtoSender; | ||
use crate::types::{ArcBool, CapnProtoSender}; | ||
use crate::update_tab::UpdateTabUpdate; | ||
use crate::utils::send_conn_state; | ||
use crate::watch::{WatchReceiver, Watched}; | ||
|
@@ -356,6 +356,10 @@ impl SharedState { | |
(*shared_data).auto_survey_data.alt = Some(alt); | ||
(*shared_data).auto_survey_data.requested = false; | ||
} | ||
pub fn log_to_std(&self) -> ArcBool { | ||
let shared_data = self.lock().expect(SHARED_STATE_LOCK_MUTEX_FAILURE); | ||
(*shared_data).log_to_std.clone() | ||
} | ||
} | ||
|
||
impl Deref for SharedState { | ||
|
@@ -401,6 +405,7 @@ pub struct SharedStateInner { | |
pub(crate) advanced_networking_update: Option<AdvancedNetworkingState>, | ||
pub(crate) auto_survey_data: AutoSurveyData, | ||
pub(crate) sbp_logging_stats_state: Option<SbpLoggingStatsState>, | ||
pub(crate) log_to_std: ArcBool, | ||
} | ||
impl SharedStateInner { | ||
pub fn new() -> SharedStateInner { | ||
|
@@ -427,6 +432,7 @@ impl SharedStateInner { | |
advanced_networking_update: None, | ||
auto_survey_data: AutoSurveyData::new(), | ||
sbp_logging_stats_state: None, | ||
log_to_std: ArcBool::new_with(true), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.