Skip to content

Commit 0052e7e

Browse files
authored
Merge pull request #1073 from katsuNakajima/log_json
サーバーのログ出力形式をJSONにする
2 parents 14f7c35 + ad6696d commit 0052e7e

File tree

3 files changed

+20
-44
lines changed

3 files changed

+20
-44
lines changed

atcoder-problems-backend/Cargo.lock

Lines changed: 10 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

atcoder-problems-backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
[dependencies]
99
# Logging
1010
log = "0.4"
11-
simple_logger = "1.11"
11+
fern = "0.6.0"
1212

1313
rand = "0.7.3"
1414
chrono = "0.4"

atcoder-problems-backend/src/utils.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use fern;
12
use log::LevelFilter;
2-
use simple_logger::SimpleLogger;
33

44
use anyhow::Result;
55

@@ -24,11 +24,13 @@ pub const EXCLUDED_USERS: [&str; 17] = [
2424
];
2525

2626
pub fn init_log_config() -> Result<()> {
27-
SimpleLogger::new()
28-
.with_level(LevelFilter::Info)
29-
.with_module_level("sqlx", LevelFilter::Warn)
30-
.with_module_level("tide", LevelFilter::Warn)
31-
.with_module_level("surf", LevelFilter::Warn)
32-
.init()?;
27+
fern::Dispatch::new()
28+
.format(|out, message, _record| out.finish(format_args!("{}", message)))
29+
.level(LevelFilter::Info)
30+
.level_for("sqlx", LevelFilter::Warn)
31+
.level_for("tide", LevelFilter::Warn)
32+
.level_for("surf", LevelFilter::Warn)
33+
.chain(std::io::stdout())
34+
.apply()?;
3335
Ok(())
3436
}

0 commit comments

Comments
 (0)