nmccready / angular-simple-logger

Basic logger with level logging which can also be independent.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build in support for the `debug` npm module

zacronos opened this issue · comments

It would be great if there were an option to turn on full debug support via this module: https://www.npmjs.com/package/debug

This is really meant for angular only so I am not sure how this is relevant.

The debug module works in browsers, it's just a set of features that apply to the "debug" log level. Some of the features only apply to backend use cases, but the ability to turn on debug selectively in certain modules and not others would be quite useful.

cool

I like the idea, but would we not have to pull in browserify and or webpack which would increase the size of this lib substantially?

Nope, it is available through bower, browser-ready.

I'm digging into this; it does look like debug api is in the midst of a transition. master is much different in the browser than 2.2.0 .

How do you imagine this fitting into the API, so I can design this appropriately.

Here is how it is used in the browser currently.

http://plnkr.co/edit/C4PcSxUhLKywBzuKUqLu

I would bet $ people would not like the fact that window.debug is overwritten by loading this library. The Readme states you can window.myDebug = require("debug"); but this is only if CommonJS is loaded. So I would have to browserify this.

I would imagine the .spawn() function could take a module name, like: var logger = nemSimpleLogger.spawn('worker:a');

Hmm. Looking at this a little, I would think that rather than having the user include the debug module either directly or via bower, it would make more sense for angular-simple-logger to vendor the debug module into its dist. Hopefully you can vendor it in via a gulp task which wraps it with something conceptually like:

(function (callback) {
  var debugOrig = window.debug;
  <-- vendored debug code -->
  var debugModule = window.debug;
  window.debug = debugOrig;
  callback(debugModule);
})(callbackToSaveDebug);

The 2 key elements to that being the gulp task to make that happen appropriately, and how to define callbackToSaveDebug such that it can save the value of the debug module to be used by angular-simple-logger.

Oh yeah I can wrap it no prob , forgot about that :) .. duh

Ahh awesome the spawning will work great; it will also work if someone wants to using it as a decorator as well np.

@zacronos PR is out closing ticket