Download / ulog

The universal logger
https://ulog.js.org
MIT License
86 stars 19 forks source link

Config polling interval does not stop on resetting config #55

Open Download opened 3 years ago

Download commented 3 years ago

Split off from #52 where @Messj1 wrote:

BTW: There seems to be a bug :bug: in the code. The interval get not stopped if someone call ulog.set("log_config", {}); https://github.com/Download/ulog/blob/2aa34192c1804a143eaf0931fc196c712549a8f0/mods/config/index.js#L43-L44

Maybe a destructor callback would do the trick. At the end, watch.browser.js would look something like that:

module.exports = function(ulog, pollingTimeout) {
  const intervalId = window.setInterval(watchFnc, pollingTimeout);
  return () => {
      window.clearInterval(intervalId);
  }
}
Download commented 3 years ago

@Messj1 can you elaborate on this one? I agree that starting a timer and never stopping it is not the best. But I'm not sure where ulog.set('log_config', {}) comes in. In ulog, you only get and set strings. Not objects. Also, the log_config setting is unused in the browser. It allows you to configure the path to the config file on Node JS.