How to quickly and conveniently disable all console.log statements in my code?

后端 未结 28 2594
深忆病人
深忆病人 2020-11-22 16:48

Is there any way to turn off all console.log statements in my JavaScript code, for testing purposes?

28条回答
  •  清歌不尽
    2020-11-22 17:29

    I developed a library for this usecase: https://github.com/sunnykgupta/jsLogger

    Features:

    1. It safely overrides the console.log.
    2. Takes care if the console is not available (oh yes, you need to factor that too.)
    3. Stores all logs (even if they are suppressed) for later retrieval.
    4. Handles major console functions like log, warn, error, info.

    Is open for modifications and will be updated whenever new suggestions come up.

提交回复
热议问题