Customized Log Format Output In Rust With tracing
Introduction
I'm working on the interface for Neopoligen. The end goal is to get really good error messages. At the start, I'm just trying to make them readable. This is the code I'm using to do that.
```cargo
= "0.1"
tracing-subscriber = "0.3"
```
use ;
use fmt;
tracing
Output:
INFO This is an info message
DEBUG This is a debug message
Details
-
The code creates a custom tracing_subscriber formatter via
format
with calls to customize the output -
Without applying the formatter, the output text would be:
2024-04-23T14:14:56.835109Z INFO _active_nvim_run: This is the log message
-
.without_time
turns off the time stamp -
.with_target
turns off some diagnostic info about the function that's running the code -
The
.with_ansi
line turns off formatting that adds colors for the terminal. Without it, you'd see something like:^[[32m INFO ^[[0m This is the log message
-- end of line --