Skip to content

Commit

Permalink
リリースビルドでログをファイルに出力
Browse files Browse the repository at this point in the history
  • Loading branch information
yuma140902 committed Nov 12, 2021
1 parent 19f6f5a commit 3555444
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 52 deletions.
52 changes: 2 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ tokio = { version = "1.13.0", features = ["rt"] }
uuid = { version = "0.8", features = ["serde", "v4"] }
toml = "0.5"
tracing = "0.1"
tracing-subscriber = "0.2"
tracing-subscriber = "0.3"
tracing-unwrap = "0.9"
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::collections::VecDeque;
use std::ffi::CString;
use std::fs::File;
use std::sync::Arc;
use std::sync::Mutex;

Expand Down Expand Up @@ -59,7 +60,16 @@ fn main() {
} else {
tracing::Level::INFO
};
tracing_subscriber::fmt().with_max_level(level).init();
if cfg!(debug_assertions) {
tracing_subscriber::fmt().pretty().with_max_level(level).init();
} else {
let log_file = File::create("blocking-io-log.txt").unwrap_or_log();
tracing_subscriber::fmt()
.with_writer(Mutex::new(log_file))
.with_ansi(false)
.with_max_level(level)
.init();
};
}

let setting = Setting::load().expect_or_log("設定ファイルの読み込みに失敗");
Expand Down

0 comments on commit 3555444

Please sign in to comment.