123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- 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() {
-
- return ('WebkitAppearance' in document.documentElement.style) ||
-
- (window.console && (console.firebug || (console.exception && console.table))) ||
-
-
- (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
- }
- exports.formatters.j = function(v) {
- return JSON.stringify(v);
- };
- 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));
-
-
-
- var index = 0;
- var lastC = 0;
- args[0].replace(/%[a-z%]/g, function(match) {
- if ('%%' === match) return;
- index++;
- if ('%c' === match) {
-
-
- lastC = index;
- }
- });
- args.splice(lastC, 0, c);
- return args;
- }
- 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) {}
- return r;
- }
- exports.enable(load());
- function localstorage(){
- try {
- return window.localStorage;
- } catch (e) {}
- }
|