statiqdev / Statiq.Framework

A flexible and extensible static content generation framework for .NET.
https://statiq.dev/framework
MIT License
425 stars 74 forks source link

Log output has wonky background/foreground colors in Rider #257

Closed ociaw closed 1 year ago

ociaw commented 1 year ago

Currently the background and foreground colors are explicitly set in ConsoleLogMessage, which makes the log output on light terminals difficult to read in JetBrains Rider: Statiq log output displayed in a JetBrains Rider terminal; the background color of the terminal itself is white, while the background color of individual characters is black (JetBrains Rider, Visual Studio Light theme)

Interestingly the issue remains when using a dark theme, since Rider apparently inverts the colors anyway: Statiq log output displayed in a JetBrains Rider terminal; the background color of the terminal itself is dark grey, while the background color of individual characters is white (JetBrains Rider, Rider Melon Dark theme)

It looks like Konsole handles it much better, though it's not perfect: Statiq log output displayed in a Konsole terminal; the background color of the terminal is pale yellow, while the background of the Statiq output is dark blue

I've worked around it by adjusting the console colors to match Statiq, though it's less than ideal. I see a few potential fixes:

1) Don't explicitly setting the background color to Black in ConsoleLogMessage - though this could also cause issues if someone has their terminal background lightly colored 2) Allow the background/foreground colors to be configurable 3) Dynamically adjust colors based on terminal settings (is that even possible?) 4) Ignore it, since it could be argued that this is more of a Rider bug than a Statiq bug.

daveaglick commented 1 year ago

To the extent that this can be improved in Statiq, I'm all for doing so - especially since I'm a heavy Rider user myself. What's interesting is that I use light themes and haven't noticed this behavior:

image

It's been a while since I've been in this code, but I think what might be going on is that the "default" console background is black and most console emulators treat a black background as transparent, which is why it works in many cases including mine. Your case is interesting though because that's obviously not happening, and the black background is treated explicitly. Any ideas why the black background is showing up in your console? Is it a standard Windows terminal, PowerShell, or something else?

I'm wondering if just not setting a background will do the trick. I seem to remember that there was a reason I had to, but maybe that's been long fixed/overcome and there's no longer a need to. Running some quick tests right now it didn't seem to have a detrimental impact removing the background color entirely. I'll play around with it a little more and will just go ahead and ship it without if I don't hit any snags - if there's an issue, users will file issues and I can revert.

ociaw commented 1 year ago

That's fixed it, thanks. I'm running Linux (Fedora 37 KDE), which is probably where the discrepancy is from. I thought that since it's built in, terminal behavior would be consistent across platforms, but I guess that's not the case.