I developed a library for this usecase: https://github.com/sunnykgupta/jsLogger
Features:
- It safely overrides the console.log.
- Takes care if the console is not available (oh yes, you need to factor that too.)
- Stores all logs (even if they are suppressed) for later retrieval.
- Handles major console functions like
log
, warn
, error
, info
.
Is open for modifications and will be updated whenever new suggestions come up.