-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add option forceConsole #2276
Add option forceConsole #2276
Conversation
Add new option to the Console transport: forceConsole (Boolean): when true, force transport to use console log/warn/error instead of write. With this option, VSCode terminal will work without setting the "outputCapture" to "std".
Hmm, this seems to change default behavior, which might require a major version bump. VSCode might be a better place for this to be fixed, especially if the impact is intended only for that one environment. |
I believe this would resolve my feature request #2175 and others like it. I'm not sure how it would change the default behavior since the default value is false, so the statement:
would evaluate to the same as before if this prop wasn't set. |
Found this open PR after spending way too long trying to find out why I wasn't getting Winston console logs in VSCode. Turns out it's because I'm attaching to the process (required in my case), and stderr/stdout can't be captured in that config. Setting Would love to have this option available as it would enable VSCode to actually see the logs I want to write with Winston. |
I agree that it doesn't look like this is introducing a breaking change. I'm okay with merging this but it would be good to have some documentation (even just a comment) somewhere explaining that you may need to set this option with VSCode. Enough people are using VSCode that maybe that's worth a line in the README? @neilenns , would you feel up to the task of adding some brief documentation somewhere for this? (can be a separate PR - also anyone else reading this is more than welcome to do this 🙏) |
Yep, I'd be happy to and will later today! |
Cool, you rock!! 🎸 |
I, like presumably many others, do |
@Jimbly @neilenns If you think saving a copy of the global |
I'm not an expert at all in this unfortunately, just someone who got tripped up with the whole "can't capture in vscode when attaching to node.js" mess. |
Looking at this a bit more, the changed proposed in #2474 might fix the infinite recursion issue @Jimbly hit? Since it doesn't call |
I manually applied a variation of the change in #2474 and confirmed it does not have any issue with infinite recursion. In my main import mainLogger from "@utils/logger";
console.log = mainLogger.log.bind(mainLogger); And everything logs correctly to the console. |
Add new option to the Console transport:
forceConsole (Boolean): when true, force transport to use console log/warn/error instead of write. With this option, VSCode terminal will work without setting the "outputCapture" to "std".