0

Say I have a function imported from a library

import doSomething from 'someLibrary';

And doSomething has a console.log() call inside of it. So, when I call do something

doSomething();

Some message is logged to the console. How do I call the function doSomething without it logging anything to the console?

  • 1
    Not something you can easily do. You can overwrite the global `console.log` with your own custom function that swallows input, but that will nullify any logging from happening including your own. – Jared Smith Aug 18 '21 at 18:53
  • 3
    If `someLibrary` is open-source on GitHub or similar, reach out to the developer and let them know that is happening. Since `someLibrary` is likely to be in `node_modules` (or similar), it is considered "Vendor Code" and shouldn't be modified directly. Alternatively, make your own "fork" and patch the issue yourself. – Tim Lewis Aug 18 '21 at 18:55
  • It is the firebase admin-sdk, `admin.auth().updateUser`. If the user email is updated, it logs a link for the user to reset their email to the previous one. I only see this log, however, when called in my tests using the emulator, and not when called on the actual site. – Roland Killian Aug 18 '21 at 19:05
  • I was mainly wondering if this is possible to do elegantly, but I guess not. – Roland Killian Aug 18 '21 at 19:10

1 Answers1

0

Try this:

{
    let console = {log: ()=>{}};
    doSomething();
}
thie
  • 1
  • 6