Skip to content

Conversation

NotEvenANeko
Copy link

@NotEvenANeko NotEvenANeko commented Sep 5, 2025

Refactor tracing to spdlog-rs for logging, which is behind the spdlog-rs feature flag, and tracing codes should be removed before this PR gets merged.

The original tracing logger is behind the tracing feature flag now.

Haven't written comments yet...

And blocked by SpriteOvO/spdlog-rs#93 .

This closes #486 .

cc @SpriteOvO

@eatradish
Copy link
Member

eatradish commented Sep 5, 2025

Initially it looks good, but what I'm wondering is whether we should just replace the tracing family directly with spdlog instead of optional?

@NotEvenANeko
Copy link
Author

Yeah we should replace tracing with spdlog, current codes is just convenient for debugging. I'll delete the tracing codes after spdlog parts are good to go.

Copy link

@SpriteOvO SpriteOvO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a brief look and most of it seems to be fine. I'll probably merge SpriteOvO/spdlog-rs#93 in the next couple days. In the meantime, you can try removing the use of tracing from oma entirely.

src/main.rs Outdated
Comment on lines 304 to 321
let rotating_sink = if let Ok(log_file) = &log_file {
Some(
AsyncPoolSink::builder()
.sink(Arc::new(
RotatingFileSink::builder()
.base_path(&log_file)
.formatter(formatter.clone())
.rotation_policy(RotationPolicy::Hourly)
.build()
.unwrap(),
))
.overflow_policy(spdlog::sink::OverflowPolicy::DropIncoming)
.build()
.unwrap(),
)
} else {
None
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RotatingFileSink should not rotate hourly as oma did not do so. Could try RotationPolicy::FileSize(u64::MAX) and set max_files(config.save_log_count()).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, file size is set to 10MB.

src/main.rs Outdated
.join("oma")
};

let log_file = create_log_file(&log_dir);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating variants for filenames has been done internally by spdlog-rs, so oma no longer needs to create names manually.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@SpriteOvO
Copy link

FYI, SpriteOvO/spdlog-rs#93 is merged.

@NotEvenANeko
Copy link
Author

I'll work on this PR tomorrow.

@NotEvenANeko
Copy link
Author

spdlog-rs is set to main-dev branch now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace the current logging system with spdlog-rs
3 participants