-
Notifications
You must be signed in to change notification settings - Fork 55
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
No colored output (with default settings and "colors" feature activated) #64
Comments
I can't reproduce the issue so far :-| |
I'm using Arch Linux (which is a rolling-release Linux distribution, so all my software should pretty much be up-to-date. My Linux kernel version is 5.8.5-arch1-1). rustc: 1.46.0 (04488afe3 2020-08-24) I tried the following terminals: Kitty, Alacritty, and directly on a TTY (so no graphical user interface and no virtual terminal emulator). What is odd, is that colored output works with every other logging crate that I have tested (that supports colored output). Is there anything I do to help to debug this? Of all the logging crates I have tested, I like flexi_logger the most (but colored output is essential for me). |
Did you set the environment variable FLEXI_LOGGER_PALETTE? |
I have tried to set FLEXI_LOGGER_PALETTE (copied from the docs), but it didn't change anything (otherwise that variable is unset). |
Are you piping the output explicitly through other programs? Since 0.15.8, colors are switched off if the output does not go to a terminal. |
I'm not piping the output through anything. I just run 'cargo run -p test-drive' to run the 'main' function of the main binary crate in a cargo workspace. I even tested to 'ctrl-alt-F2' to a TTY (so there isn't even a terminal program or a graphical user interface (XServer in my case). But there still is no color. And as I wrote other logging crates (which I like much less than flexi_logger) work without a problem. Very strange, isn't it? :) |
I now also tested in the popular 'rxvt-unicode' terminal emulator, but still no color. |
I still have no clue what can go wrong. |
You mean this example, right? The output of this example has colored output. When I execute the following code, however, there isn't colored output: use log::{info};
fn main() {
let logger_config = "trace";
flexi_logger::Logger::with_str(logger_config)
.check_parser_error()
.expect("Logger config string formatted incorrectly")
.log_target(flexi_logger::LogTarget::StdOut)
.format_for_stdout(flexi_logger::colored_detailed_format)
.format_for_stderr(flexi_logger::colored_detailed_format)
.start()
.expect("Failed to start logger");
info!("test");
} I even tried to run the above code from a binary within this repo (in case there is some conflict in my project). If you mean the performance example: There is no colored output. |
I mean the colors example - it is now (version 0.16.1) extended and prints out some additional information that flexi_logger uses internally to decide if coloring should be done. |
Ah, okay. Before I cloned this repo and ran the colors example this way, but it seems this repo only has 0.16.0. Now I copied the colors example to my project (which has 0.16.1) and ran it. The output is |
How did you run it? Did you switch off the default features? |
I copied the source code from 'colors.rs' to 'src/bin/flexi_logger_test.rs' and ran
No, my cargo.toml contains 'flexi_logger = "0.16.1"' |
What is strange is that, as mentioned above, when I clone this repo (0.16.0), and run The output is:
And the last lines are colored. Also, I just have realized a potential problem: In my test with 0.16.1, I copied the 'colors' example from this repo – could this be a problem? I'm not aware of a way to run an example of an installed crate, and I don't know where the repo for 0.16.1 is (this repo only has one branch which is 0.16.0). |
Looks like I didn‘t yet push the last change to github, but that doesn’t matter. 0.16.1 improved something unrelated to the coloring. If you copy the source file to a different crate, then the feature would have to be defined there, with the right dependencies :-| The output you‘ve shown in the previous comment, and the colored lines below, show clearly that the „low level“ coloring mechanics work as expected. So something more highlevel must go wrong with your flexi_logger usage, if it fails to use colors in the same environment. |
Oh, right, I didn't read the source code – sorry for the false alarm!
Is there any logging that can be activated within If not, wouldn't it be possible (for me) to add a few If so, can you recommend any places where this would make especially sense? In the meantime, I discovered and switched to the |
The following diff should do it (4 dbg! calls inserted, and a derive):
|
Sorry for the delay! With your patch I get the following output:
I use my example from this comment. Does this give you any clue about what's going on? |
And I ran this by cloning your repo, applying the patch, creating |
I thought my colors weren't working, and then I tried the colors example in this repo as @d4h0 mentioned. Turns out that my colors actually were working, except that in my own project I was testing with I don't know if it might apply to you @d4h0 but thought it would be helpful to share my point of confusion in case that happened to be it. |
Thanks for pointing this out! |
Hi,
Thanks for creating 'flexi_logger'!
For some reason, I don't get any colored output with the default settings (or any other settings I tried).
When I run
cargo run --example colors
, however, I get colored output (the output of Cargo is colored, as well).Do you have any idea what the problem could be?
I'm using
flexi_logger = "0.15.12"
in Cargo.toml (so the "colors" feature is activated), and besides the defaults I have tested the following:It would be nice if it somehow would be possible to activate colored output, because 'flexi_logger' looks really nice :)
The text was updated successfully, but these errors were encountered: