Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.49k stars 589 forks source link

Document method of disabling logging #394

Closed crrobinson14 closed 5 years ago

crrobinson14 commented 5 years ago

I discovered that there is a built-in way used by the test suite to reduce the logging. It feels like something that should be documented because it's useful to control this in many apps:

import logger from '@nozbe/watermelondb/utils/common/logger';
logger.silence();

I'm happy to file a PR to document this. This ticket is just to ask what is the most appropriate file to add it to.

Also, if you are open to it, I would include in the PR enhancing this to be a log level rather than on/off. The logger is set up with four log levels already but there is only the option to have all on or off. We could allow the logger to report database issues and warnings without logging the timing of every single query...

radex commented 5 years ago

I'm happy to file a PR to document this.

Please do!

Also, if you are open to it, I would include in the PR enhancing this to be a log level

Sure! I think it would also be good to be able to just pass an object supplying your custom logger

This ticket is just to ask what is the most appropriate file to add it to.

Don't have a good idea right now -- maybe start a new "Tips & Tricks" document under "Advanced"? https://github.com/Nozbe/WatermelonDB/tree/master/docs#advanced-guides — there's a lot of undocumented tips like this :)

crrobinson14 commented 5 years ago

Sorry this took so long. What do you think of the PR above? I added an actual document called Logging because it felt like something that can be expanded over time.

isaachinman commented 5 days ago

For what it's worth, this seems like really strange behaviour to me. Overriding a global singleton logger is going to be subject to race conditions and a lot of other weird behaviour.

I suggest that a logLevel property is added/maintained. If that is undesirable, it would make a lot more sense to add and optional logger to the configuration, so that users can fine tune things how they like.

crrobinson14 commented 5 days ago

@isaachinman This thread has been dead for 4 years. If you would like to suggest a change, you would best off starting a new thread and/or (ideally) opening a new PR with your suggestion.