| |
| |
| |
| |
| |
|
|
| 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(); |
|
|
| |
| |
| |
|
|
| exports.colors = [ |
| 'lightseagreen', |
| 'forestgreen', |
| 'goldenrod', |
| 'dodgerblue', |
| 'darkorchid', |
| 'crimson' |
| ]; |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| function useColors() { |
| |
| |
| |
| if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { |
| return true; |
| } |
|
|
| |
| |
| return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || |
| |
| (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || |
| |
| |
| (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || |
| |
| (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); |
| } |
|
|
| |
| |
| |
|
|
| exports.formatters.j = function(v) { |
| try { |
| return JSON.stringify(v); |
| } catch (err) { |
| return '[UnexpectedJSONParseError]: ' + err.message; |
| } |
| }; |
|
|
|
|
| |
| |
| |
| |
| |
|
|
| function formatArgs(args) { |
| var useColors = this.useColors; |
|
|
| args[0] = (useColors ? '%c' : '') |
| + this.namespace |
| + (useColors ? ' %c' : ' ') |
| + args[0] |
| + (useColors ? '%c ' : ' ') |
| + '+' + exports.humanize(this.diff); |
|
|
| if (!useColors) return; |
|
|
| var c = 'color: ' + this.color; |
| args.splice(1, 0, c, 'color: inherit') |
|
|
| |
| |
| |
| var index = 0; |
| var lastC = 0; |
| args[0].replace(/%[a-zA-Z%]/g, function(match) { |
| if ('%%' === match) return; |
| index++; |
| if ('%c' === match) { |
| |
| |
| lastC = index; |
| } |
| }); |
|
|
| args.splice(lastC, 0, c); |
| } |
|
|
| |
| |
| |
| |
| |
| |
|
|
| function log() { |
| |
| |
| return 'object' === typeof console |
| && console.log |
| && Function.prototype.apply.call(console.log, console, arguments); |
| } |
|
|
| |
| |
| |
| |
| |
| |
|
|
| function save(namespaces) { |
| try { |
| if (null == namespaces) { |
| exports.storage.removeItem('debug'); |
| } else { |
| exports.storage.debug = namespaces; |
| } |
| } catch(e) {} |
| } |
|
|
| |
| |
| |
| |
| |
| |
|
|
| function load() { |
| var r; |
| try { |
| r = exports.storage.debug; |
| } catch(e) {} |
|
|
| |
| if (!r && typeof process !== 'undefined' && 'env' in process) { |
| r = process.env.DEBUG; |
| } |
|
|
| return r; |
| } |
|
|
| |
| |
| |
|
|
| exports.enable(load()); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| function localstorage() { |
| try { |
| return window.localStorage; |
| } catch (e) {} |
| } |
|
|