Skip to content
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

How to disable console.log #379

Closed
jeansoonsik opened this issue Dec 19, 2018 · 18 comments
Closed

How to disable console.log #379

jeansoonsik opened this issue Dec 19, 2018 · 18 comments
Assignees
Labels
enhancement New feature or improvement.

Comments

@jeansoonsik
Copy link

Normally our application logging with a standard format to console in docker environment, the logging is directly capture from console output. I am facing an issue that the smart contract having multiple functions with a same name, the ethers will output a warning message to console.

WARNING: Multiple definitions for XXXX

Do you have any idea to disable the console.log inside ethers library?

@ricmoo
Copy link
Member

ricmoo commented Dec 19, 2018

I probably should add something to the errors to disable warnings. There isn’t anything easy to do until I update that though. Do you need function overloading? That itself can lead to bugs... :s

@ricmoo
Copy link
Member

ricmoo commented Dec 19, 2018

As I think about this more, I think future versions won’t allow ambiguous calls. If there is a transfer(uint) and transfer(address) then both explicit functions will be available, but calling transfer will throw an ambiguous call exception.

I’ll experiment with this in the v5 branch tomorrow.

For v4, I’ll just add an errors.disableWarnings = true option.

@ricmoo ricmoo self-assigned this Dec 19, 2018
@ricmoo ricmoo added enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. labels Dec 19, 2018
@ricmoo
Copy link
Member

ricmoo commented Jan 15, 2019

You should now be able to set the internal log level:

ethers.errors.setLogLevel("debug");

ethers.errors.setLogLevel("default");
ethers.errors.setLogLevel("info");

ethers.errors.setLogLevel("warn");

ethers.errors.setLogLevel("error");

ethers.errors.setLogLevel("off");

Let me know if that works for you.

Thanks! :)

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Jan 16, 2019
@ricmoo
Copy link
Member

ricmoo commented Jan 16, 2019

Closing this now, but I monitor closed issues. Let me know if there are any issues, or feel free to re-open. :)

Thanks! :)

@wighawag
Copy link

How do I disable log in v5 ?
I'd like to get rid of these duplicate definition message in the log

@ricmoo
Copy link
Member

ricmoo commented Nov 22, 2019

Ah yes, I noticed a few weeks ago I have not added that yet. I will add it today.

@wighawag
Copy link

Any update on this ?

@ricmoo
Copy link
Member

ricmoo commented Feb 20, 2020

Ah yes, I just added this the other day, but haven’t published the change yet.

I’ll do that today with a few other changes that need to be published.

@ricmoo
Copy link
Member

ricmoo commented Feb 27, 2020

By the way, this should be available in the latest published version. :)

@RobertoSnap
Copy link

Useing "ethers": "^5.0.0-beta.175",

Getting this while trying to turn of this logs:

image

@ricmoo
Copy link
Member

ricmoo commented Mar 9, 2020

I think you need ethers.utils.Logger.setLogLevel instead. Let me know if that doesn’t solve it...

@wighawag
Copy link

With "ethers": "^5.0.0-beta.175",
and

const ethers = require('ethers');
ethers.utils.Logger.setLogLevel('off');

I get the following error :

TypeError: ethers.utils.Logger.setLogLevel is not a function

Was it added in beta.175 ?

@ricmoo
Copy link
Member

ricmoo commented Mar 21, 2020

There was a bug that prevented warnings from being properly suppressed. Please try out 5.0.0-beta.177 and use the ethers.utils.Logger.setLogLevel("off") to try it out.

Let me know if there are any problems. :)

@wighawag
Copy link

wighawag commented Apr 16, 2020

I still get the issue

TypeError: ethers.utils.Logger.setLogLevel is not a function in some project where the dependency on ethers is "ethers": "^5.0.0-beta.181",

I guess it is related to how other project depend on other ethers packages
I noticed the various packages have a dependency on "@ethersproject/logger": ">=5.0.0-beta.129",

it should be "@ethersproject/logger": ">=5.0.0-beta.136", no ?

@wighawag
Copy link

I workaround it by adding

"resolutions": {
    "@ethersproject/logger": "5.0.0-beta.136"
 }

@ajb413
Copy link

ajb413 commented Jul 27, 2020

I'm using 5.0.7 in my ts rollup build:

src/index.ts:9:33 - error TS2345: Argument of type '"off"' is not assignable to parameter of type 'LogLevel'.

9 ethers.utils.Logger.setLogLevel('off'); // turn off warnings

Found 1 error.

Shouldn't this work? Is there an export of LogLevel on the ethers class? Thank you.

@ricmoo
Copy link
Member

ricmoo commented Jul 28, 2020

@ajb413

It’s an enum, so can you try Logger.levels.OFF instead of the string "off"? Let me know if that still doesn’t work.

@ajb413
Copy link

ajb413 commented Jul 28, 2020

whoops wrong browser tab, meant to post in #947

anyway:

ethers.utils.Logger.setLogLevel(ethers.utils.Logger.levels.ERROR); // turn off warnings

is the cure, I only want to turn off warnings because an ABI has an overloaded event that was triggering the warning. Thank you @ricmoo !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement.
Projects
None yet
Development

No branches or pull requests

5 participants