Skip to content

Formatting help #140

Answered by emabee
mr-entropia asked this question in Q&A
Jun 14, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can create your own function, anywhere in your codebase, similar to those that are defined in flexi_logger.

Here's a modified copy of with_threads (which is in src/formats.rs).

pub fn with_thread_no_codeline(
    w: &mut dyn std::io::Write,
    now: &mut DeferredNow,
    record: &Record,
) -> Result<(), std::io::Error> {
    write!(
        w,
        "[{}] T[{}] {} {}",
        now.format(TS_DASHES_BLANK_COLONS_DOT_BLANK),
        thread::current().name().unwrap_or("<unnamed>"),
        record.level(),
        &record.args()
    )
}

Use it the same way as the predefined methods, as described in the code example.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mr-entropia
Comment options

Answer selected by mr-entropia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants