cgkineo / adapt-devtools

Tools for developing and testing Adapt courses
GNU General Public License v3.0
8 stars 6 forks source link

Noisy console log messages #96

Open swashbuck opened 3 weeks ago

swashbuck commented 3 weeks ago

Subject of the issue

In end-trickle.js, statements about when Trickle starts and ends are output to the console.

Trickle started
Trickle ended
Trickle started
Trickle ended
Trickle started
Trickle ended

This adds unnecessary messages to the console that are not valuable unless you are specifically troubleshooting a Trickle issue.

Screenshot 2024-06-20 at 10 24 35 AM

I would suggest one of the following:

  1. Remove these console messages entirely
  2. Change these to console.debug()
  3. Add a new option to suppress all console log messages originating from Dev Tools. Something like _quietMode or _suppressConsoleLogs.
oliverfoster commented 3 weeks ago

Reference line:

https://github.com/cgkineo/adapt-devtools/blob/b8b77caac43dfe7e95214335ebf57b1f36fd1ac8/js/end-trickle.js#L5

There are four extra pipes/function to the console api which can help filter the output:

console.debug
console.info
console.warn
console.error

Messages like those in this issue which are for debugging, should not be posted to console.log but instead indirectly to console.debug through logging.debug.

Adapt has a logging system which should be used instead of direct console logs, this can be seen at the url below: https://github.com/adaptlearning/adapt-contrib-core/blob/9bc7db2480b8f7b3dfb9579637fc9f94cdd2d6fa/js/logging.js#L51-L86

Adapt's logging system is configured in the config.json as can be seen in this schema: https://github.com/adaptlearning/adapt-contrib-core/blob/9bc7db2480b8f7b3dfb9579637fc9f94cdd2d6fa/schema/config.schema.json#L348-L382

It is possible to set a default logging level in the config.json such that only messages from the specified level upward are output to the console. The logging levels are listed in the logLevelEnum file.

Otherwise, here is an article on how to subsequently filter the console in a browser, such that the browser console only shows messages of the various types:

https://medium.com/@rhyneav/chromes-console-filters-and-how-to-use-them-63f2ff1c148b

It is probably wise not to remove logs used for debugging, but it is a good idea to output them to the correct pipe and to use the Adapt's APIs to do so.