Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug.enable() disabling previously enabled namespaces #730

Closed
tabcat opened this issue Nov 17, 2019 · 1 comment
Closed

debug.enable() disabling previously enabled namespaces #730

tabcat opened this issue Nov 17, 2019 · 1 comment

Comments

@tabcat
Copy link

tabcat commented Nov 17, 2019

i'm having a some issues with enabling debug namespaces dynamically using debug.enable(). it seems that when i enable one thing and then enable something else, the first thing i enabled is no longer enabled?
i've remedied this for now by enabling the root namespace with a wildcard and everything is fine.

heres some of the code

const setLogOutputs = (self, scope, log) => {
  if (!log) {
    self.log = debug(scope)
    debug.enable(`${scope}*`) // DOING NOW
  } else {
    self.log = log.extend(scope)
  }
  self.log.error = self.log.extend('error')
  if (self.events) {
    self.log.log = (...p) => {
      try {
        self.events.emit('debug', ...p)
      } catch (e) { console.error(e) }
    }

    self.log.error.log = (...p) => {
      try {
        self.events.emit('error', ...p)
      } catch (e) { console.error(e) }
     debug.enable(`${self.log.namespace},${self.log.error.namespace}`) // DID BEFORE
    }
    self.events.on('error', console.log)
  }
}
@Qix-
Copy link
Member

Qix- commented Nov 17, 2019

Duplicate of #425.

@Qix- Qix- closed this as completed Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants