added Quiet Errors option #309

This commit is contained in:
DustInDark
2021-12-20 01:13:23 +09:00
parent c081130147
commit a7c6be4182
2 changed files with 16 additions and 2 deletions

View File

@@ -68,6 +68,7 @@ fn build_app<'a>() -> ArgMatches<'a> {
-t --thread-number=[NUMBER] 'Thread number (default: optimal number for performance)'
-s --statistics 'Prints statistics of event IDs'
-q --quiet 'Quiet mode. Do not display the launch banner'
-Q --quiet-errors 'Quiet errors mode. Do not display errors or save error logs'
--contributors 'Prints the list of contributors'";
App::new(&program)
.about("Hayabusa: Aiming to be the world's greatest Windows event log analysis tool!")

View File

@@ -43,6 +43,11 @@ lazy_static! {
"./logs/errorlog-{}.log",
Local::now().format("%Y%m%d_%H%M%S")
);
pub static ref QUIERT_ERRORS_FLAG: bool = configs::CONFIG
.read()
.unwrap()
.args
.is_present("quiet-errors");
}
#[derive(Copy, Clone)]
@@ -235,12 +240,20 @@ impl AlertMessage {
/// ERRORメッセージを表示する関数。error_log_flagでfalseの場合は外部へのエラーログの書き込みは行わずに指定されたwを用いた出力のみ行う。trueの場合はwを用いた出力を行わずにエラーログへの出力を行う
pub fn alert<W: Write>(w: &mut W, contents: String) -> io::Result<()> {
writeln!(w, "[ERROR] {}", contents)
if QUIERT_ERRORS_FLAG {
writeln!(w, "[ERROR] {}", contents)
} else {
ok()
}
}
// WARNメッセージを表示する関数
pub fn warn<W: Write>(w: &mut W, contents: String) -> io::Result<()> {
writeln!(w, "[WARN] {}", contents)
if QUIERT_ERRORS_FLAG {
writeln!(w, "[WARN] {}", contents)
} else {
ok()
}
}
/// エラーログへのERRORメッセージの出力数を確認して、0であったらファイルを削除する。1以上あればエラーを書き出した旨を標準出力に表示する