-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Unable to see any console output on windows, plus set_pattern not working? #3242
Comments
The STDOUT/STDERR handle got by stdout_color_sink is considered invalid. spdlog/include/spdlog/sinks/wincolor_sink-inl.h Lines 162 to 170 in 63f0875
You should not call |
If I don't call those functions there's still no output from spdlog, but then there's also no output from Maybe I need to use |
As far as the official documentation is concerned, yes: https://learn.microsoft.com/en-us/windows/console/console-handles |
I posted it here because it's only speedlog that's not working but it probably has to do with orders of initialization so thanks for that. And, do you have any idea what could be going on with the log formatting not working on windows? |
No. On windows I am planning to use the windows console color api (that's what all the nasty defines are about) but that's not the question. The problem is spdlog is not applying my custom format string to messages written to the logfile. Here's where I'm at: However, when I write to the logfile on windows, spdlog is not using my custom pattern for the log message ( P.S. This is a behavior I'm only seeing on Windows so far. |
Not a console? |
I continue in my efforts to convert our old logger over to spdlog, and for the most part have been successful. Currently, on my mac the app is producing both a logfile and colored output to the console as I expect it to.
However, I decided to run some tests in windows, because I also wanted to try some code that was before just disabled on windows builds. After much trial and error, it should be working but alas, I get no output on the console.
Let me first walk you through the relevant parts of my code...
I have a SpdLogger class, that constructs and configures the various loggers. You'll noticed there's an odd loop where several loggers are created, what that does is iterate over an enum containing all valid logger names, construct each of them and register them with spdlog, as well as in an unordered_map I can use to look the pointers up without blocking the spdlog registry.
Then there's the
StdErrGreabber
struct, which essentially captures output to stderr, and formats and redirects it to stdout.The
getLogger
function is called in the variousSpdLogger::debug/trace/etc
functions.The writeHeader function is using its own special logger to prevent duplicate output.
On macOS, I am getting:
"[%T]:::%^%n / %l%$::: %v"
On windows, I am getting:
Below are the relevant code snippets.
P.S. I tried turning off color because I read an old issue saying using color on windows could cause output to be lost, but it didn't really make any difference.
The text was updated successfully, but these errors were encountered: