Formatting help #140
-
Hi guys. I've succesfully set up flexi_logger in my project and can write stuff to a log. Great! I'm using the built in
I'm happy with the format for now, during development phase. However, when I finish development and build a release binary, I would like to have a formatter that omits the source file and line number. Everything else can stay. How can I write a formatter to accomplish this? I've tried reading the documentation but maybe I'm too stupid to understand it, so a little help is much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 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. |
Beta Was this translation helpful? Give feedback.
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 insrc/formats.rs
).Use it the same way as the predefined methods, as described in the code example.