(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
angular.module('nemLogging', []);
|
|
|
|
angular.module('nemLogging').provider('nemDebug', function (){
|
|
var ourDebug = null;
|
|
ourDebug = require('debug');
|
|
|
|
this.$get = function(){
|
|
//avail as service
|
|
return ourDebug;
|
|
};
|
|
|
|
//avail at provider, config time
|
|
this.debug = ourDebug;
|
|
|
|
return this;
|
|
});
|
|
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
|
slice = [].slice;
|
|
|
|
angular.module('nemLogging').provider('nemSimpleLogger', [
|
|
'nemDebugProvider', function(nemDebugProvider) {
|
|
var LEVELS, Logger, _debugCache, _fns, _isValidLogObject, _maybeExecLevel, _wrapDebug, i, key, len, nemDebug, val;
|
|
nemDebug = nemDebugProvider.debug;
|
|
_debugCache = {};
|
|
_fns = ['debug', 'info', 'warn', 'error', 'log'];
|
|
LEVELS = {};
|
|
for (key = i = 0, len = _fns.length; i < len; key = ++i) {
|
|
val = _fns[key];
|
|
LEVELS[val] = key;
|
|
}
|
|
_maybeExecLevel = function(level, current, fn) {
|
|
if (level >= current) {
|
|
return fn();
|
|
}
|
|
};
|
|
_isValidLogObject = function(logObject) {
|
|
var isValid, j, len1;
|
|
isValid = false;
|
|
if (!logObject) {
|
|
return isValid;
|
|
}
|
|
for (j = 0, len1 = _fns.length; j < len1; j++) {
|
|
val = _fns[j];
|
|
isValid = (logObject[val] != null) && typeof logObject[val] === 'function';
|
|
if (!isValid) {
|
|
break;
|
|
}
|
|
}
|
|
return isValid;
|
|
};
|
|
|
|
/*
|
|
Overide logeObject.debug with a nemDebug instance
|
|
see: https://github.com/visionmedia/debug/blob/master/Readme.md
|
|
*/
|
|
_wrapDebug = function(namespace, logObject) {
|
|
var debugInstance, j, len1, newLogger;
|
|
if (_debugCache[namespace] == null) {
|
|
_debugCache[namespace] = nemDebug(namespace);
|
|
}
|
|
debugInstance = _debugCache[namespace];
|
|
newLogger = {};
|
|
for (j = 0, len1 = _fns.length; j < len1; j++) {
|
|
val = _fns[j];
|
|
newLogger[val] = val === 'debug' ? debugInstance : logObject[val];
|
|
}
|
|
return newLogger;
|
|
};
|
|
Logger = (function() {
|
|
function Logger($log1) {
|
|
var fn1, j, len1, level, logFns;
|
|
this.$log = $log1;
|
|
this.spawn = bind(this.spawn, this);
|
|
if (!this.$log) {
|
|
throw 'internalLogger undefined';
|
|
}
|
|
if (!_isValidLogObject(this.$log)) {
|
|
throw '@$log is invalid';
|
|
}
|
|
this.doLog = true;
|
|
logFns = {};
|
|
fn1 = (function(_this) {
|
|
return function(level) {
|
|
logFns[level] = function() {
|
|
var args;
|
|
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
if (_this.doLog) {
|
|
return _maybeExecLevel(LEVELS[level], _this.currentLevel, function() {
|
|
var ref;
|
|
return (ref = _this.$log)[level].apply(ref, args);
|
|
});
|
|
}
|
|
};
|
|
return _this[level] = logFns[level];
|
|
};
|
|
})(this);
|
|
for (j = 0, len1 = _fns.length; j < len1; j++) {
|
|
level = _fns[j];
|
|
fn1(level);
|
|
}
|
|
this.LEVELS = LEVELS;
|
|
this.currentLevel = LEVELS.error;
|
|
}
|
|
|
|
Logger.prototype.spawn = function(newInternalLogger) {
|
|
if (typeof newInternalLogger === 'string') {
|
|
if (!_isValidLogObject(this.$log)) {
|
|
throw '@$log is invalid';
|
|
}
|
|
if (!nemDebug) {
|
|
throw 'nemDebug is undefined this is probably the light version of this library sep debug logggers is not supported!';
|
|
}
|
|
return _wrapDebug(newInternalLogger, this.$log);
|
|
}
|
|
return new Logger(newInternalLogger || this.$log);
|
|
};
|
|
|
|
return Logger;
|
|
|
|
})();
|
|
this.decorator = [
|
|
'$log', function($delegate) {
|
|
var log;
|
|
log = new Logger($delegate);
|
|
log.currentLevel = LEVELS.debug;
|
|
return log;
|
|
}
|
|
];
|
|
this.$get = [
|
|
'$log', function($log) {
|
|
return new Logger($log);
|
|
}
|
|
];
|
|
return this;
|
|
}
|
|
]);
|
|
|
|
},{"debug":2}],2:[function(require,module,exports){
|
|
|
|
/**
|
|
* This is the web browser implementation of `debug()`.
|
|
*
|
|
* Expose `debug()` as the module.
|
|
*/
|
|
|
|
exports = module.exports = require('./debug');
|
|
exports.log = log;
|
|
exports.formatArgs = formatArgs;
|
|
exports.save = save;
|
|
exports.load = load;
|
|
exports.useColors = useColors;
|
|
exports.storage = 'undefined' != typeof chrome
|
|
&& 'undefined' != typeof chrome.storage
|
|
? chrome.storage.local
|
|
: localstorage();
|
|
|
|
/**
|
|
* Colors.
|
|
*/
|
|
|
|
exports.colors = [
|
|
'lightseagreen',
|
|
'forestgreen',
|
|
'goldenrod',
|
|
'dodgerblue',
|
|
'darkorchid',
|
|
'crimson'
|
|
];
|
|
|
|
/**
|
|
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
* and the Firebug extension (any Firefox version) are known
|
|
* to support "%c" CSS customizations.
|
|
*
|
|
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
*/
|
|
|
|
function useColors() {
|
|
// is webkit? http://stackoverflow.com/a/16459606/376773
|
|
return ('WebkitAppearance' in document.documentElement.style) ||
|
|
// is firebug? http://stackoverflow.com/a/398120/376773
|
|
(window.console && (console.firebug || (console.exception && console.table))) ||
|
|
// is firefox >= v31?
|
|
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
(navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
|
|
}
|
|
|
|
/**
|
|
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
*/
|
|
|
|
exports.formatters.j = function(v) {
|
|
return JSON.stringify(v);
|
|
};
|
|
|
|
|
|
/**
|
|
* Colorize log arguments if enabled.
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
function formatArgs() {
|
|
var args = arguments;
|
|
var useColors = this.useColors;
|
|
|
|
args[0] = (useColors ? '%c' : '')
|
|
+ this.namespace
|
|
+ (useColors ? ' %c' : ' ')
|
|
+ args[0]
|
|
+ (useColors ? '%c ' : ' ')
|
|
+ '+' + exports.humanize(this.diff);
|
|
|
|
if (!useColors) return args;
|
|
|
|
var c = 'color: ' + this.color;
|
|
args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
|
|
|
|
// the final "%c" is somewhat tricky, because there could be other
|
|
// arguments passed either before or after the %c, so we need to
|
|
// figure out the correct index to insert the CSS into
|
|
var index = 0;
|
|
var lastC = 0;
|
|
args[0].replace(/%[a-z%]/g, function(match) {
|
|
if ('%%' === match) return;
|
|
index++;
|
|
if ('%c' === match) {
|
|
// we only are interested in the *last* %c
|
|
// (the user may have provided their own)
|
|
lastC = index;
|
|
}
|
|
});
|
|
|
|
args.splice(lastC, 0, c);
|
|
return args;
|
|
}
|
|
|
|
/**
|
|
* Invokes `console.log()` when available.
|
|
* No-op when `console.log` is not a "function".
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
function log() {
|
|
// this hackery is required for IE8/9, where
|
|
// the `console.log` function doesn't have 'apply'
|
|
return 'object' === typeof console
|
|
&& console.log
|
|
&& Function.prototype.apply.call(console.log, console, arguments);
|
|
}
|
|
|
|
/**
|
|
* Save `namespaces`.
|
|
*
|
|
* @param {String} namespaces
|
|
* @api private
|
|
*/
|
|
|
|
function save(namespaces) {
|
|
try {
|
|
if (null == namespaces) {
|
|
exports.storage.removeItem('debug');
|
|
} else {
|
|
exports.storage.debug = namespaces;
|
|
}
|
|
} catch(e) {}
|
|
}
|
|
|
|
/**
|
|
* Load `namespaces`.
|
|
*
|
|
* @return {String} returns the previously persisted debug modes
|
|
* @api private
|
|
*/
|
|
|
|
function load() {
|
|
var r;
|
|
try {
|
|
r = exports.storage.debug;
|
|
} catch(e) {}
|
|
return r;
|
|
}
|
|
|
|
/**
|
|
* Enable namespaces listed in `localStorage.debug` initially.
|
|
*/
|
|
|
|
exports.enable(load());
|
|
|
|
/**
|
|
* Localstorage attempts to return the localstorage.
|
|
*
|
|
* This is necessary because safari throws
|
|
* when a user disables cookies/localstorage
|
|
* and you attempt to access it.
|
|
*
|
|
* @return {LocalStorage}
|
|
* @api private
|
|
*/
|
|
|
|
function localstorage(){
|
|
try {
|
|
return window.localStorage;
|
|
} catch (e) {}
|
|
}
|
|
|
|
},{"./debug":3}],3:[function(require,module,exports){
|
|
|
|
/**
|
|
* This is the common logic for both the Node.js and web browser
|
|
* implementations of `debug()`.
|
|
*
|
|
* Expose `debug()` as the module.
|
|
*/
|
|
|
|
exports = module.exports = debug;
|
|
exports.coerce = coerce;
|
|
exports.disable = disable;
|
|
exports.enable = enable;
|
|
exports.enabled = enabled;
|
|
exports.humanize = require('ms');
|
|
|
|
/**
|
|
* The currently active debug mode names, and names to skip.
|
|
*/
|
|
|
|
exports.names = [];
|
|
exports.skips = [];
|
|
|
|
/**
|
|
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
*
|
|
* Valid key names are a single, lowercased letter, i.e. "n".
|
|
*/
|
|
|
|
exports.formatters = {};
|
|
|
|
/**
|
|
* Previously assigned color.
|
|
*/
|
|
|
|
var prevColor = 0;
|
|
|
|
/**
|
|
* Previous log timestamp.
|
|
*/
|
|
|
|
var prevTime;
|
|
|
|
/**
|
|
* Select a color.
|
|
*
|
|
* @return {Number}
|
|
* @api private
|
|
*/
|
|
|
|
function selectColor() {
|
|
return exports.colors[prevColor++ % exports.colors.length];
|
|
}
|
|
|
|
/**
|
|
* Create a debugger with the given `namespace`.
|
|
*
|
|
* @param {String} namespace
|
|
* @return {Function}
|
|
* @api public
|
|
*/
|
|
|
|
function debug(namespace) {
|
|
|
|
// define the `disabled` version
|
|
function disabled() {
|
|
}
|
|
disabled.enabled = false;
|
|
|
|
// define the `enabled` version
|
|
function enabled() {
|
|
|
|
var self = enabled;
|
|
|
|
// set `diff` timestamp
|
|
var curr = +new Date();
|
|
var ms = curr - (prevTime || curr);
|
|
self.diff = ms;
|
|
self.prev = prevTime;
|
|
self.curr = curr;
|
|
prevTime = curr;
|
|
|
|
// add the `color` if not set
|
|
if (null == self.useColors) self.useColors = exports.useColors();
|
|
if (null == self.color && self.useColors) self.color = selectColor();
|
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
args[0] = exports.coerce(args[0]);
|
|
|
|
if ('string' !== typeof args[0]) {
|
|
// anything else let's inspect with %o
|
|
args = ['%o'].concat(args);
|
|
}
|
|
|
|
// apply any `formatters` transformations
|
|
var index = 0;
|
|
args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
|
|
// if we encounter an escaped % then don't increase the array index
|
|
if (match === '%%') return match;
|
|
index++;
|
|
var formatter = exports.formatters[format];
|
|
if ('function' === typeof formatter) {
|
|
var val = args[index];
|
|
match = formatter.call(self, val);
|
|
|
|
// now we need to remove `args[index]` since it's inlined in the `format`
|
|
args.splice(index, 1);
|
|
index--;
|
|
}
|
|
return match;
|
|
});
|
|
|
|
if ('function' === typeof exports.formatArgs) {
|
|
args = exports.formatArgs.apply(self, args);
|
|
}
|
|
var logFn = enabled.log || exports.log || console.log.bind(console);
|
|
logFn.apply(self, args);
|
|
}
|
|
enabled.enabled = true;
|
|
|
|
var fn = exports.enabled(namespace) ? enabled : disabled;
|
|
|
|
fn.namespace = namespace;
|
|
|
|
return fn;
|
|
}
|
|
|
|
/**
|
|
* Enables a debug mode by namespaces. This can include modes
|
|
* separated by a colon and wildcards.
|
|
*
|
|
* @param {String} namespaces
|
|
* @api public
|
|
*/
|
|
|
|
function enable(namespaces) {
|
|
exports.save(namespaces);
|
|
|
|
var split = (namespaces || '').split(/[\s,]+/);
|
|
var len = split.length;
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
if (!split[i]) continue; // ignore empty strings
|
|
namespaces = split[i].replace(/\*/g, '.*?');
|
|
if (namespaces[0] === '-') {
|
|
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
|
} else {
|
|
exports.names.push(new RegExp('^' + namespaces + '$'));
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Disable debug output.
|
|
*
|
|
* @api public
|
|
*/
|
|
|
|
function disable() {
|
|
exports.enable('');
|
|
}
|
|
|
|
/**
|
|
* Returns true if the given mode name is enabled, false otherwise.
|
|
*
|
|
* @param {String} name
|
|
* @return {Boolean}
|
|
* @api public
|
|
*/
|
|
|
|
function enabled(name) {
|
|
var i, len;
|
|
for (i = 0, len = exports.skips.length; i < len; i++) {
|
|
if (exports.skips[i].test(name)) {
|
|
return false;
|
|
}
|
|
}
|
|
for (i = 0, len = exports.names.length; i < len; i++) {
|
|
if (exports.names[i].test(name)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Coerce `val`.
|
|
*
|
|
* @param {Mixed} val
|
|
* @return {Mixed}
|
|
* @api private
|
|
*/
|
|
|
|
function coerce(val) {
|
|
if (val instanceof Error) return val.stack || val.message;
|
|
return val;
|
|
}
|
|
|
|
},{"ms":4}],4:[function(require,module,exports){
|
|
/**
|
|
* Helpers.
|
|
*/
|
|
|
|
var s = 1000;
|
|
var m = s * 60;
|
|
var h = m * 60;
|
|
var d = h * 24;
|
|
var y = d * 365.25;
|
|
|
|
/**
|
|
* Parse or format the given `val`.
|
|
*
|
|
* Options:
|
|
*
|
|
* - `long` verbose formatting [false]
|
|
*
|
|
* @param {String|Number} val
|
|
* @param {Object} options
|
|
* @return {String|Number}
|
|
* @api public
|
|
*/
|
|
|
|
module.exports = function(val, options){
|
|
options = options || {};
|
|
if ('string' == typeof val) return parse(val);
|
|
return options.long
|
|
? long(val)
|
|
: short(val);
|
|
};
|
|
|
|
/**
|
|
* Parse the given `str` and return milliseconds.
|
|
*
|
|
* @param {String} str
|
|
* @return {Number}
|
|
* @api private
|
|
*/
|
|
|
|
function parse(str) {
|
|
str = '' + str;
|
|
if (str.length > 10000) return;
|
|
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
|
|
if (!match) return;
|
|
var n = parseFloat(match[1]);
|
|
var type = (match[2] || 'ms').toLowerCase();
|
|
switch (type) {
|
|
case 'years':
|
|
case 'year':
|
|
case 'yrs':
|
|
case 'yr':
|
|
case 'y':
|
|
return n * y;
|
|
case 'days':
|
|
case 'day':
|
|
case 'd':
|
|
return n * d;
|
|
case 'hours':
|
|
case 'hour':
|
|
case 'hrs':
|
|
case 'hr':
|
|
case 'h':
|
|
return n * h;
|
|
case 'minutes':
|
|
case 'minute':
|
|
case 'mins':
|
|
case 'min':
|
|
case 'm':
|
|
return n * m;
|
|
case 'seconds':
|
|
case 'second':
|
|
case 'secs':
|
|
case 'sec':
|
|
case 's':
|
|
return n * s;
|
|
case 'milliseconds':
|
|
case 'millisecond':
|
|
case 'msecs':
|
|
case 'msec':
|
|
case 'ms':
|
|
return n;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Short format for `ms`.
|
|
*
|
|
* @param {Number} ms
|
|
* @return {String}
|
|
* @api private
|
|
*/
|
|
|
|
function short(ms) {
|
|
if (ms >= d) return Math.round(ms / d) + 'd';
|
|
if (ms >= h) return Math.round(ms / h) + 'h';
|
|
if (ms >= m) return Math.round(ms / m) + 'm';
|
|
if (ms >= s) return Math.round(ms / s) + 's';
|
|
return ms + 'ms';
|
|
}
|
|
|
|
/**
|
|
* Long format for `ms`.
|
|
*
|
|
* @param {Number} ms
|
|
* @return {String}
|
|
* @api private
|
|
*/
|
|
|
|
function long(ms) {
|
|
return plural(ms, d, 'day')
|
|
|| plural(ms, h, 'hour')
|
|
|| plural(ms, m, 'minute')
|
|
|| plural(ms, s, 'second')
|
|
|| ms + ' ms';
|
|
}
|
|
|
|
/**
|
|
* Pluralization helper.
|
|
*/
|
|
|
|
function plural(ms, n, name) {
|
|
if (ms < n) return;
|
|
if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
|
|
return Math.ceil(ms / n) + ' ' + name + 's';
|
|
}
|
|
|
|
},{}]},{},[1]);
|