Drakulix / simplelog.rs

Simple Logging Facility for Rust
https://docs.rs/simplelog/
Apache License 2.0
433 stars 73 forks source link

how do i strip formattting when using WriteLogger & TermLogger in the same CombinedLogger ? #112

Closed Ryder17z closed 2 years ago

Ryder17z commented 2 years ago

Should be possible to set up, but I don't see how to.

Drakulix commented 2 years ago

What exactly do you mean with "strip formatting", would you mind to share some code and a quick example, what it is you are trying to achieve?

You can initialize WriteLogger and TermLogger with different or the same Config to handle formatting, before initializing a CombinedLogger.

Ryder17z commented 2 years ago

It's simple. I want to have formatting options enabled for TermLogger but not for WriteLogger.

Currently I'm initializing both with the default config under CombinedLogger because I can't get the config set up right for WriteLogger.

On Sun, 7 Aug 2022, 17:43 Victoria Brekenfeld, @.***> wrote:

What exactly do you mean with "strip formatting", would you mind to share some code and a quick example, what it is you are trying to achieve?

You can initialize WriteLogger and TermLogger with different or the same Config to handle formatting, before initializing a CombinedLogger.

— Reply to this email directly, view it on GitHub https://github.com/Drakulix/simplelog.rs/issues/112#issuecomment-1207434254, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPIOP37MAU2ESVKYUBOFX3VX7KRFANCNFSM55XWX5VQ . You are receiving this because you authored the thread.Message ID: @.***>

Drakulix commented 2 years ago

So you could instead do something like this:

let write_config = ConfigBuilder::new()
  .set_max_level(LevelFilter::Off)
  .set_time_level(LevelFilter::Off)
  .set_thread_level(LevelFilter::Off)
  .set_target_level(LevelFilter::Off)
  .set_location_level(LevelFilter::Off)
  .build();

CombinedLogger::init(
    vec![
        TermLogger::new(LevelFilter::Warn, Config::default(), TerminalMode::Mixed, ColorChoice::Auto),
        WriteLogger::new(LevelFilter::Info, write_config, File::create("my_rust_binary.log").unwrap()),
    ]
).unwrap();

That would disable all additional information, that can be written by simplelog for the WriteLogger.

Ryder17z commented 2 years ago

Thanks, I'll play around with that.

On Mon, 8 Aug 2022, 11:54 Victoria Brekenfeld, @.***> wrote:

So you could instead do something like this:

let write_config = ConfigBuilder::new() .set_max_level(LevelFilter::Off) .set_time_level(LevelFilter::Off) .set_thread_level(LevelFilter::Off) .set_target_level(LevelFilter::Off) .set_location_level(LevelFilter::Off) .build();

CombinedLogger::init( vec![ TermLogger::new(LevelFilter::Warn, Config::default(), TerminalMode::Mixed, ColorChoice::Auto), WriteLogger::new(LevelFilter::Info, write_config, File::create("my_rust_binary.log").unwrap()), ] ).unwrap();

That would disable all additional information, that can be written by simplelog for the WriteLogger.

— Reply to this email directly, view it on GitHub https://github.com/Drakulix/simplelog.rs/issues/112#issuecomment-1207910574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPIOP32UGKQ3FQNGIYHP5LVYDKNHANCNFSM55XWX5VQ . You are receiving this because you authored the thread.Message ID: @.***>

Drakulix commented 2 years ago

Feel free to re-open, if you have problems setting that up.

Ryder17z commented 2 years ago

I still can't find a way to strip <tag> </tag> from WriteLogger

Ryder17z commented 2 years ago

Feel free to re-open, if you have problems setting that up.

Can not reopen due to repo settings.

Drakulix commented 2 years ago

I still can't find a way to strip <tag> </tag> from WriteLogger

What do you mean by <tag>? Not sure which part of the log message you are referring to

Ryder17z commented 2 years ago

E. G. From the front page example: info!("I can write bold text or use tags to color it</>");

These tags I want to strip.

On Tue, 9 Aug 2022, 11:18 Victoria Brekenfeld, @.***> wrote:

I still can't find a way to strip from WriteLogger

What do you mean by ? Not sure which part of the log message you are referring to

— Reply to this email directly, view it on GitHub https://github.com/Drakulix/simplelog.rs/issues/112#issuecomment-1209128167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPIOP6A6SRWBSNKOLGT67LVYIO55ANCNFSM55XWX5VQ . You are receiving this because you authored the thread.Message ID: @.***>

Drakulix commented 2 years ago

Ah, you are referring to the paris feature. That is indeed not configurable right now and that issue is tracked here: https://github.com/Drakulix/simplelog.rs/issues/98

Pull requests are very welcome, support for implementing this feature should have landed in paris by now. :)

Ryder17z commented 2 years ago

Alright. I wasn't sure if it was connected or not. Thanks for the clarification