Open tahpot opened 2 years ago
As verida-js
is a library that aims to be used by other applications we should avoid putting a specific library that would force the consuming application to use the same or would conflict with another logger they use..
For debugging, it could be as easy as having a debug
property in the configuration (of Client
and others for instance), then in the code, we would conditionally use console
to log. Normally, this debug
property shouldn't be used on Production.
For Production usage, some libraries provide another way: taking an instance of a Logger
in the configuration. This instance must implement an known interface (for loggers, typically with the methods error
, warn
, info
, debug
, etc.). Then in the Verida library we would use this instance to make all sort of logs.
The apps consuming the library can define their logger instance as they want: the log level, the destination, etc.
This obviously requires more effort to implement than the debug
property + console
.
See https://github.com/log4js-node/log4js-api