Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clion log glitch #271

Open
mikart143 opened this issue Sep 4, 2020 · 3 comments
Open

Clion log glitch #271

mikart143 opened this issue Sep 4, 2020 · 3 comments
Labels
P-low Priority: Low slog-term crate: slog-term

Comments

@mikart143
Copy link

Hello!
I noticed very strange bug.
image
My code:

    let log_path = "your_log_file_path.log";
    let file = OpenOptions::new()
        .create(true)
        .write(true)
        .truncate(true)
        .open(log_path)
        .unwrap();
    let file_decorator = slog_term::PlainDecorator::new(file);
    let file_drain = slog_term::FullFormat::new(file_decorator).build().fuse();
    let file_drain = slog_async::Async::new(file_drain).build().fuse();


    let term_decorator = slog_term::TermDecorator::new().build();
    let term_drain = slog_term::FullFormat::new(term_decorator).build().fuse();
    let term_drain = slog_async::Async::new(term_drain).build().fuse();
    let logger = slog::Logger::root(slog::Duplicate::new(file_drain, term_drain).fuse(), o!("version" => env!("CARGO_PKG_VERSION")));

    let _scope_guard = slog_scope::set_global_logger(logger);
    let _log_guard = slog_stdlog::init().unwrap();

    info!("Starting program...");

Logs in file looks good and also when I run app from linux terminal too.
Clion: 2020.2.1

@dpc
Copy link
Collaborator

dpc commented Sep 4, 2020

That's something to do with color handling, which is automatically not being done when logging to non-TTY device. I wonder if it's slog printing something weird, or just clion terminal emulator.

@mikart143
Copy link
Author

When using other loggers like fern, everything works perfect. I also turn on terminal emulation in clion. It looks like slog handle colors in the other way.

@dpc
Copy link
Collaborator

dpc commented Sep 5, 2020

@Techcable Techcable added slog-term crate: slog-term P-low Priority: Low labels Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-low Priority: Low slog-term crate: slog-term
Projects
None yet
Development

No branches or pull requests

3 participants