-
Notifications
You must be signed in to change notification settings - Fork 62
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
Why is yahoo-finance2 outputting a lot of unwanted text on my Mac Terminal? #702
Comments
It should only call the cookie code once per library load, as it checks it's cookie jar each call to see if it has already pulled one. Currently the cookie jar is instance specific. If you are running the library directly in the terminal, you are reloading the library each time making it so it fetches the cookies each time. To avoid this, you would want to set up your quote calls in a way where you keep the library instance running (like in a expressJS or ReactJS app). |
Thanks for your reply. Each time I run my node.js app which loads yahoo-finance2 via the line of code: const yahooFinance = require('yahoo-finance2').default; this text is printed out in the Mac's Terminal. In prior versions of yahoo-finance2, this text never appeared. Is there any way to suppress the text? |
There was the option for custom logging that was integrated recently, you should be able to set that higher than debug to not show those I think (they're all logger.debug()). I haven't tried yet myself though |
Thanks very much for that suggestion. Would you be able to give the exact line of code I can enter to try to suppress these unwanted lines of text on the console? I looked at the documentation, but could not work out what code to add. Much appreciated. |
There should be a |
FWIW, this worked for me as of 2.11.3: // See https://github.com/gadicc/node-yahoo-finance2/issues/778
// the error message
// "We expected a redirect to guce.yahoo.com, but got https://finance.yahoo.com/quote"
// _always_ gets written to console.error, instead of the configured logger.error
console.error = () => {};
yahooFinance.setGlobalConfig({
// Disable all logging
logger: {
info: () => {},
warn: () => {},
debug: () => {},
error: () => {}
}
}); See: (obviously, disabling |
Thanks for the example, @zadjii-msft, which I think everyone will appreciate. I've opened an umbrella issue to track future log changes when we get a chance to work on them (won't be soon, unfortunately). |
Bug Report
Describe the bug
When getting the latest S&P 500 index data using the following node.js code, running on an Apple Mac Terminal:
var quote = await yahooFinance.quote("^GSPC")
I notice that yahoo-finance2 now outputs a lot of text on the Terminal. The text that it outputs is:
How can I prevent this text output from appearing on the Terminal?
Minimal Reproduction
const yahooFinance = require('yahoo-finance2').default;
(async () => {
var quote = await yahooFinance.quote("^GSPC");
}) ()
Environment
Using node.js version v21.1.0.
npm version 10.2.0.
Additional Context
The text was updated successfully, but these errors were encountered: