rust-lang / log

Logging implementation for Rust
https://docs.rs/log
Apache License 2.0
2.18k stars 252 forks source link

Is it possible to group logs? #600

Closed gavrilikhin-d closed 6 months ago

gavrilikhin-d commented 10 months ago

Is it possible to group logs like in js (console.group(), console.groupEnd())?

It's useful to visually create hierarchies of logs, e.g:

Compiling code
|--- Lexing
|--- Parsing
|--- Compiling imported module#1
|      |--- Lexing
|      |--- Parsing
|
| ---Compiling imported module#2
       |--- Lexing
       |--- Parsing
Thomasdezeeuw commented 10 months ago

We don't provide something exactly like group and groupEnd. However we have some tools you can use to group logs. You can set the target to any string to correlate messages, in additional you have the (Rust source code) module name. You can opt in to the currently unstable (https://github.com/rust-lang/log/issues/436) key-values, which allows you to add key-value pair, with which you can add your own group info.

KodrAus commented 6 months ago

Structured logging support has been recently stabilized. You can read about it in the docs here.

I'll go ahead and close this one now, but please feel free to open new issues with any new questions you might have!