IITC-CE / ingress-intel-total-conversion

intel.ingress.com total conversion user script with some new features. Should allow easier extension of the intel map.
https://iitc.app
ISC License
285 stars 110 forks source link

Debug output: make conditional #26

Closed johnd0e closed 4 years ago

johnd0e commented 5 years ago

iitc writes a lot of debug info to console log, but it's not useful for general use, and only adds 'noice' to log. It would be more useful if such thing were wrapped in something like this:

function window.debug.log (info) {
  if (window.debug.ENABLE_LOG) {
    console.log (info)
  }
}

Condition could be more complex:

function window.debug.log (level,info) {
  if (debug.ENABLE_LOG.ALL or debug.ENABLE_LOG[level]) {
    console.log (info)
  }
}

In order to control the condition ENABLE_LOG we could use additional plugin.

johnd0e commented 5 years ago

May be we should use some library.

angel93ayora commented 5 years ago

What would be the requirements of a logger?

filter by levels? filter by tags?

i think that exporting the log stack to a string could be useful to present a user the logs without opening the dev tools, could be useful for mobile devices. Showing it at the hidden debug tab at comm or from the about IITC for example.

johnd0e commented 5 years ago

See comment in upper post. May be similar functionality in other form.

johnd0e commented 5 years ago

could be useful for mobile devices.

IITCm has own console.

angel93ayora commented 5 years ago

could be useful for mobile devices.

IITCm has own console.

yes, also desktop has, for less experienced users could be simplier that is only an idea, totally optional

johnd0e commented 5 years ago

@angel93ayora Well, may be. We could add 'share log' link to 'about iitc' dialog.

johnd0e commented 5 years ago

Another feature that I would like to have: optional popup notifications about errors.

Most of time we use iitc with closed console window, so we need to be notified about errors somehow.

It may be simple notification, or even pop-out console replacement.

angel93ayora commented 5 years ago

i think that feature is not present on any of the libraries you said

angel93ayora commented 5 years ago

my logger supports modules while storing all messages on the same stack, you can filter by module and level/minLevel and the filtered result can be printed through console or retrieved as a string

also not depending on a external library would give us the chance to insert desired features, like the one you said

johnd0e commented 5 years ago

log4javascript has some similar. And I can list more (like erudaconsole).

Actually I do not expect that out-of-the-box, but want our logger to have some relevant extension-points.

E.g. ulog has 'formatters' feature, which possibly can be hooked for our purposes. Haven't tried thought.

johnd0e commented 5 years ago

@angel93ayora Yeah, I will try to setup both.

I do not mind against custom logger, but as every new custom code - it needs debugging itself. There may be some unexpected caveats, etc.