TUI Difficulty stats for past few blocks (#805)
* added mining subview, changed main menu selection * collecting difficulty stats from miner * add diff calc view, separate server stats * rustfmt * block difficulty data output * rustfmt * ensure diff data is always shown * don't write to stderr when tui running
This commit is contained in:
+14
-4
@@ -38,6 +38,9 @@ fn convert_log_level(in_level: &LogLevel) -> Level {
|
||||
lazy_static! {
|
||||
/// Flag to observe whether logging was explicitly initialised (don't output otherwise)
|
||||
static ref WAS_INIT: Mutex<bool> = Mutex::new(false);
|
||||
/// Flag to observe whether tui is running, and we therefore don't want to attempt to write
|
||||
/// panics to stdout
|
||||
static ref TUI_RUNNING: Mutex<bool> = Mutex::new(false);
|
||||
/// Static Logging configuration, should only be set once, before first logging call
|
||||
static ref LOGGING_CONFIG: Mutex<LoggingConfig> = Mutex::new(LoggingConfig::default());
|
||||
|
||||
@@ -47,6 +50,10 @@ lazy_static! {
|
||||
let config = LOGGING_CONFIG.lock().unwrap();
|
||||
let slog_level_stdout = convert_log_level(&config.stdout_log_level);
|
||||
let slog_level_file = convert_log_level(&config.file_log_level);
|
||||
if config.tui_running.is_some() && config.tui_running.unwrap() {
|
||||
let mut tui_running_ref = TUI_RUNNING.lock().unwrap();
|
||||
*tui_running_ref = true;
|
||||
}
|
||||
|
||||
//Terminal output drain
|
||||
let terminal_decorator = slog_term::TermDecorator::new().build();
|
||||
@@ -141,9 +148,12 @@ fn send_panic_to_log() {
|
||||
),
|
||||
}
|
||||
//also print to stderr
|
||||
eprintln!(
|
||||
"Thread '{}' panicked with message:\n\"{}\"\nSee grin.log for further details.",
|
||||
thread, msg
|
||||
);
|
||||
let tui_running = TUI_RUNNING.lock().unwrap().clone();
|
||||
if !tui_running {
|
||||
eprintln!(
|
||||
"Thread '{}' panicked with message:\n\"{}\"\nSee grin.log for further details.",
|
||||
thread, msg
|
||||
);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ pub struct LoggingConfig {
|
||||
pub log_file_path: String,
|
||||
/// Whether to append to log or replace
|
||||
pub log_file_append: bool,
|
||||
/// Whether the tui is running (optional)
|
||||
pub tui_running: Option<bool>,
|
||||
}
|
||||
|
||||
impl Default for LoggingConfig {
|
||||
@@ -57,6 +59,7 @@ impl Default for LoggingConfig {
|
||||
file_log_level: LogLevel::Trace,
|
||||
log_file_path: String::from("grin.log"),
|
||||
log_file_append: false,
|
||||
tui_running: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user