Skip to content

Commit 2228983

Browse files
committed
refactor: simplify init_logger return type
1 parent 3a8af65 commit 2228983

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

Cargo.lock

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

src/main.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use reqwest::Client;
3939
use rustix::stdio::stdout;
4040
// FIXME: `spdlog::error` is conflict with `mod error`
4141
use spdlog::{
42-
Level, LevelFilter, Logger, debug, default_logger, info, init_log_crate_proxy,
43-
prelude::error,
42+
Level, LevelFilter, Logger, debug, info, init_log_crate_proxy,
43+
prelude::error as error2,
4444
set_default_logger,
4545
sink::{AsyncPoolSink, RotatingFileSink, RotationPolicy, StdStreamSink},
4646
warn,
@@ -188,7 +188,7 @@ fn main() {
188188
console_subscriber::init();
189189

190190
#[cfg(not(feature = "tokio-console"))]
191-
let (_guard, file) = init_logger(&oma, &config);
191+
let file = init_logger(&oma, &config);
192192

193193
debug!(
194194
"Run oma with args: {} (pid: {})",
@@ -284,10 +284,7 @@ fn init_localizer() {
284284
LANGUAGE_LOADER.set_use_isolating(false);
285285
}
286286

287-
fn init_logger(
288-
oma: &OhManagerAilurus,
289-
config: &Config,
290-
) -> (Option<Arc<Logger>>, anyhow::Result<String>) {
287+
fn init_logger(oma: &OhManagerAilurus, config: &Config) -> anyhow::Result<String> {
291288
let debug = oma.global.debug;
292289
let dry_run = oma.global.dry_run;
293290

@@ -350,9 +347,9 @@ fn init_logger(
350347
let logger = logger_builder.build().unwrap();
351348

352349
set_default_logger(Arc::new(logger));
353-
init_log_crate_proxy()?;
350+
init_log_crate_proxy().unwrap();
354351

355-
(Some(default_logger()), Ok(log_file))
352+
Ok(log_file.to_string_lossy().to_string())
356353
}
357354

358355
#[inline]

0 commit comments

Comments
 (0)