-
Notifications
You must be signed in to change notification settings - Fork 2
[CPP-242][CPP-243]LogLevel, uprev py2many, fix broken csv/sbp logging. #79
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
2 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -16,11 +16,10 @@ use std::{ | |
}; | ||
|
||
use crate::cli_options::*; | ||
use crate::common_constants::LogLevel; | ||
use crate::console_backend_capnp as m; | ||
use crate::constants::LOG_WRITER_BUFFER_MESSAGE_COUNT; | ||
use crate::errors::*; | ||
use crate::log_panel::{splitable_log_formatter, LogPanelWriter}; | ||
use crate::log_panel::{splitable_log_formatter, LogLevel, LogPanelWriter}; | ||
use crate::output::{CsvLogging, SbpLogging}; | ||
use crate::types::{ClientSender, FlowControl, ServerState, SharedState}; | ||
use crate::utils::{refresh_loggingbar, refresh_navbar}; | ||
|
@@ -112,6 +111,12 @@ fn handle_cli( | |
if let Some(folder) = opt.dirname { | ||
shared_state.set_logging_directory(PathBuf::from(folder)); | ||
} | ||
let log_level = if let Some(log_level_) = opt.log_level { | ||
(*log_level_).clone() | ||
} else { | ||
LogLevel::INFO | ||
}; | ||
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); | ||
if let Some(sbp_log) = opt.sbp_log { | ||
|
@@ -161,8 +166,7 @@ impl Server { | |
}; | ||
let shared_state = SharedState::new(); | ||
let server_state = ServerState::new(); | ||
refresh_navbar(&mut client_send.clone(), shared_state.clone()); | ||
refresh_loggingbar(&mut client_send.clone(), shared_state.clone()); | ||
|
||
let logger = Logger::builder() | ||
.buf_size(LOG_WRITER_BUFFER_MESSAGE_COUNT) | ||
.formatter(splitable_log_formatter) | ||
|
@@ -171,7 +175,6 @@ impl Server { | |
.unwrap(); | ||
|
||
log::set_boxed_logger(Box::new(logger)).expect("Failed to set logger"); | ||
log::set_max_level(log::LevelFilter::Info); | ||
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. Moved this to handle_cli function to set based off cli if provided. |
||
|
||
// Handle CLI Opts. | ||
handle_cli( | ||
|
@@ -180,6 +183,8 @@ impl Server { | |
client_send.clone(), | ||
shared_state.clone(), | ||
); | ||
refresh_navbar(&mut client_send.clone(), shared_state.clone()); | ||
refresh_loggingbar(&mut client_send.clone(), shared_state.clone()); | ||
thread::spawn(move || loop { | ||
let buf = server_recv.recv(); | ||
if let Ok(buf) = buf { | ||
|
@@ -316,14 +321,13 @@ impl Server { | |
} | ||
m::message::LogLevelFront(Ok(cv_in)) => { | ||
let shared_state_clone = shared_state.clone(); | ||
let mut shared_data = shared_state_clone | ||
.lock() | ||
.expect(SHARED_STATE_LOCK_MUTEX_FAILURE); | ||
let log_level = cv_in | ||
.get_log_level() | ||
.expect(CAP_N_PROTO_DESERIALIZATION_FAILURE); | ||
(*shared_data).log_panel.log_level = | ||
let log_level = | ||
LogLevel::from_str(log_level).expect(CONVERT_TO_STR_FAILURE); | ||
shared_state_clone.set_log_level(log_level); | ||
refresh_navbar(&mut client_send.clone(), shared_state.clone()); | ||
} | ||
m::message::SolutionVelocityStatusFront(Ok(cv_in)) => { | ||
let unit = cv_in | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.
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.
Needed a second type so I could overload the from_str (already set in py2many via EnumString) function to display available variants to the user if they mispell one.