huan / flash-store

FlashStore is a high-performance Key-Value Persistent Local Database using ES6 Map's API (Async & Sync), Powered by LevelDB/RocksDB/SQLite and TypeScript.
https://paka.dev/npm/flash-store
Apache License 2.0
21 stars 4 forks source link

How to mute the flash-store log, it's really verbose indeed. #98

Open su-chang opened 2 years ago

su-chang commented 2 years ago

The default log level is verbose, if we set brolog level as verbose, it would also effect flash-store.

We want to mute the flash-store log.

17:18:01 INFO PuppetWhatsApp room roomMemberList(120363020146301181@g.us)
17:18:01 VERB FlashStore get(120363020146301181@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363020464684493@g.us)
17:18:01 VERB FlashStore get(120363020464684493@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363021055257339@g.us)
17:18:01 VERB FlashStore get(120363021055257339@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363021274246512@g.us)
17:18:01 VERB FlashStore get(120363021274246512@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363021311676077@g.us)
17:18:01 VERB FlashStore get(120363021311676077@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363021318182885@g.us)
17:18:01 VERB FlashStore get(120363021318182885@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363021332004743@g.us)
17:18:01 VERB FlashStore get(120363021332004743@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363022300471408@g.us)
17:18:01 VERB FlashStore get(120363022300471408@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363022968200999@g.us)
17:18:01 VERB FlashStore get(120363022968200999@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363023107517740@g.us)
17:18:01 VERB FlashStore get(120363023107517740@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363023400897793@g.us)
17:18:01 VERB FlashStore get(120363023400897793@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363023469172577@g.us)
17:18:01 VERB FlashStore get(120363023469172577@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363023874644737@g.us)
17:18:01 VERB FlashStore get(120363023874644737@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363024921864320@g.us)
17:18:01 VERB FlashStore get(120363024921864320@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363025372855153@g.us)
17:18:01 VERB FlashStore get(120363025372855153@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363036416835658@g.us)
17:18:01 VERB FlashStore get(120363036416835658@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363037050500616@g.us)
17:18:01 VERB FlashStore get(120363037050500616@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363038050091176@g.us)
17:18:01 VERB FlashStore get(120363038050091176@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363038068267547@g.us)
17:18:01 VERB FlashStore get(120363038068267547@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363038973760072@g.us)
17:18:01 VERB FlashStore get(120363038973760072@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363039010379837@g.us)
17:18:01 VERB FlashStore get(120363039010379837@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363039118529218@g.us)
17:18:01 VERB FlashStore get(120363039118529218@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363039170086468@g.us)
17:18:01 VERB FlashStore get(120363039170086468@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363039429239881@g.us)
17:18:01 VERB FlashStore get(120363039429239881@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363039504139235@g.us)
17:18:01 VERB FlashStore get(120363039504139235@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363039973559065@g.us)
17:18:01 VERB FlashStore get(120363039973559065@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363040270659771@g.us)
17:18:01 VERB FlashStore get(120363040270659771@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363040298372116@g.us)
17:18:01 VERB FlashStore get(120363040298372116@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363040324802673@g.us)
17:18:01 VERB FlashStore get(120363040324802673@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363040551112556@g.us)
17:18:01 VERB FlashStore get(120363040551112556@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363040639631130@g.us)
17:18:01 VERB FlashStore get(120363040639631130@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363040727786922@g.us)
17:18:01 VERB FlashStore get(120363040727786922@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363041099063791@g.us)
17:18:01 VERB FlashStore get(120363041099063791@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363041133424282@g.us)
17:18:01 VERB FlashStore get(120363041133424282@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363041273841841@g.us)
17:18:01 VERB FlashStore get(120363041273841841@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363041477902786@g.us)
17:18:01 VERB FlashStore get(120363041477902786@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363042145661987@g.us)
17:18:01 VERB FlashStore get(120363042145661987@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363042758967487@g.us)
17:18:01 VERB FlashStore get(120363042758967487@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363042897232644@g.us)
17:18:01 VERB FlashStore get(120363042897232644@g.us)
17:18:01 INFO PuppetWhatsApp room roomMemberList(120363043127306839@g.us)
17:18:01 VERB FlashStore get(120363043127306839@g.us)
17:18:01 INFO BotAction syncRoom() room list from wechaty has 36 in total.
17:18:01 INFO BotAction syncRoom() room list from db has 36 in total.
17:18:01 INFO BotAction syncRoom() room list from add has 0 in total.
17:19:02 VERB ConfigManager receive maintain mode heartbeat.
17:19:23 INFO BotAction syncContact(ready=false, forceSync=false)
17:19:23 VERB Contact findAll()
17:19:23 VERB Puppet contactSearch(query=undefined, )
17:19:23 INFO PuppetWhatsApp contact contactList()
17:19:23 VERB FlashStore keys()
17:19:23 VERB FlashStore *entries({})
17:19:23 VERB FlashStore get(120363020146301181@g.us)
17:19:23 VERB FlashStore get(120363020464684493@g.us)
17:19:23 VERB FlashStore get(120363021055257339@g.us)
17:19:23 VERB FlashStore get(120363021274246512@g.us)
17:19:23 VERB FlashStore get(120363021311676077@g.us)
17:19:23 VERB FlashStore get(120363021318182885@g.us)
17:19:23 VERB FlashStore get(120363021332004743@g.us)
17:19:23 VERB FlashStore get(120363022300471408@g.us)
17:19:23 VERB FlashStore get(120363022968200999@g.us)
17:19:23 VERB FlashStore get(120363023107517740@g.us)
17:19:23 VERB FlashStore get(120363023400897793@g.us)
17:19:23 VERB FlashStore get(120363023469172577@g.us)
17:19:23 VERB FlashStore get(120363023874644737@g.us)
17:19:23 VERB FlashStore get(120363024921864320@g.us)
17:19:23 VERB FlashStore get(120363025372855153@g.us)
17:19:23 VERB FlashStore get(120363036416835658@g.us)
17:19:23 VERB FlashStore get(120363037050500616@g.us)
17:19:23 VERB FlashStore get(120363038050091176@g.us)
17:19:23 VERB FlashStore get(120363038068267547@g.us)
17:19:23 VERB FlashStore get(120363038973760072@g.us)
17:19:23 VERB FlashStore get(120363039010379837@g.us)
17:19:23 VERB FlashStore get(120363039118529218@g.us)
17:19:23 VERB FlashStore get(120363039170086468@g.us)
17:19:23 VERB FlashStore get(120363039429239881@g.us)
17:19:23 VERB FlashStore get(120363039504139235@g.us)
17:19:23 VERB FlashStore get(120363039973559065@g.us)
17:19:23 VERB FlashStore get(120363040270659771@g.us)
17:19:23 VERB FlashStore get(120363040298372116@g.us)
17:19:23 VERB FlashStore get(120363040324802673@g.us)
17:19:23 VERB FlashStore get(120363040551112556@g.us)
17:19:23 VERB FlashStore get(120363040639631130@g.us)
17:19:23 VERB FlashStore get(120363040727786922@g.us)
17:19:23 VERB FlashStore get(120363041099063791@g.us)
17:19:23 VERB FlashStore get(120363041133424282@g.us)
17:19:23 VERB FlashStore get(120363041273841841@g.us)
17:19:23 VERB FlashStore get(120363041477902786@g.us)
17:19:23 VERB FlashStore get(120363042145661987@g.us)
17:19:23 VERB FlashStore get(120363042758967487@g.us)
17:19:23 VERB FlashStore get(120363042897232644@g.us)
17:19:23 VERB FlashStore get(120363043127306839@g.us)
17:19:23 VERB FlashStore get(16505033788@c.us)
17:19:23 VERB FlashStore get(19085551024@c.us)
17:19:23 VERB FlashStore get(8613126768525@c.us)
17:19:23 VERB FlashStore get(8613141321843@c.us)
17:19:23 VERB FlashStore get(8613240330438@c.us)
17:19:23 VERB FlashStore get(8613244830920@c.us)
17:19:23 VERB FlashStore get(8613351873428@c.us)
17:19:23 VERB FlashStore get(8613810195807@c.us)
17:19:23 VERB FlashStore get(8613811254048@c.us)
17:19:23 VERB FlashStore get(8613811286503@c.us)
17:19:23 VERB FlashStore get(8613811387682@c.us)
17:19:23 VERB FlashStore get(8613947519555@c.us)
17:19:23 VERB FlashStore get(8617316842524@c.us)
17:19:23 VERB FlashStore get(8617630802710@c.us)
17:19:23 VERB FlashStore get(8618500946096@c.us)
17:19:23 VERB FlashStore get(8618710175700@c.us)
17:19:23 VERB FlashStore get(8675536336581@c.us)
17:19:23 VERB FlashStore get(868613141321843@c.us)
huan commented 2 years ago

According to the below code:

https://github.com/huan/flash-store/blob/cad208a1a69c1e32511c050167449c5edfc42060/src/config.ts#L1

The FlashStore currently using the global instance log from Brolog, which is the same as the Wechaty Puppet system is using.

A solution would be to disable the log for FlashStore by default, add a logger option in the FlashStoreOptions, and can pass a Logger to it to enable the log:

https://github.com/huan/flash-store/blob/cad208a1a69c1e32511c050167449c5edfc42060/src/flash-store.ts#L49-L51 We can use the Logger interface from Brolog here:

https://github.com/huan/brolog/blob/aa83c0940b9bffe6340d8ae9e4db6a1ad8bb9f07/src/logger.ts#L3

I'd like to accept a PR for implementing the above design.

su-chang commented 2 years ago

Thanks for you response and advice, I will do it when I'm available.