|
|
|
|
| |
| |
|
|
|
|
| exports.formatArgs = formatArgs;
|
| exports.save = save;
|
| exports.load = load;
|
| exports.useColors = useColors;
|
| exports.storage = localstorage();
|
| exports.destroy = (() => {
|
| let warned = false;
|
|
|
| return () => {
|
| if (!warned) {
|
| warned = true;
|
| console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
| }
|
| };
|
| })();
|
|
|
| |
| |
|
|
|
|
| exports.colors = [
|
| '#0000CC',
|
| '#0000FF',
|
| '#0033CC',
|
| '#0033FF',
|
| '#0066CC',
|
| '#0066FF',
|
| '#0099CC',
|
| '#0099FF',
|
| '#00CC00',
|
| '#00CC33',
|
| '#00CC66',
|
| '#00CC99',
|
| '#00CCCC',
|
| '#00CCFF',
|
| '#3300CC',
|
| '#3300FF',
|
| '#3333CC',
|
| '#3333FF',
|
| '#3366CC',
|
| '#3366FF',
|
| '#3399CC',
|
| '#3399FF',
|
| '#33CC00',
|
| '#33CC33',
|
| '#33CC66',
|
| '#33CC99',
|
| '#33CCCC',
|
| '#33CCFF',
|
| '#6600CC',
|
| '#6600FF',
|
| '#6633CC',
|
| '#6633FF',
|
| '#66CC00',
|
| '#66CC33',
|
| '#9900CC',
|
| '#9900FF',
|
| '#9933CC',
|
| '#9933FF',
|
| '#99CC00',
|
| '#99CC33',
|
| '#CC0000',
|
| '#CC0033',
|
| '#CC0066',
|
| '#CC0099',
|
| '#CC00CC',
|
| '#CC00FF',
|
| '#CC3300',
|
| '#CC3333',
|
| '#CC3366',
|
| '#CC3399',
|
| '#CC33CC',
|
| '#CC33FF',
|
| '#CC6600',
|
| '#CC6633',
|
| '#CC9900',
|
| '#CC9933',
|
| '#CCCC00',
|
| '#CCCC33',
|
| '#FF0000',
|
| '#FF0033',
|
| '#FF0066',
|
| '#FF0099',
|
| '#FF00CC',
|
| '#FF00FF',
|
| '#FF3300',
|
| '#FF3333',
|
| '#FF3366',
|
| '#FF3399',
|
| '#FF33CC',
|
| '#FF33FF',
|
| '#FF6600',
|
| '#FF6633',
|
| '#FF9900',
|
| '#FF9933',
|
| '#FFCC00',
|
| '#FFCC33'
|
| ];
|
|
|
| |
| |
| |
| |
| |
| |
|
|
|
|
|
|
| function useColors() {
|
|
|
|
|
|
|
| if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
| return true;
|
| }
|
|
|
|
|
| if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
| return false;
|
| }
|
|
|
| let m;
|
|
|
|
|
|
|
|
|
| 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 && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
|
|
| (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
| }
|
|
|
| |
| |
| |
| |
|
|
|
|
| function formatArgs(args) {
|
| args[0] = (this.useColors ? '%c' : '') +
|
| this.namespace +
|
| (this.useColors ? ' %c' : ' ') +
|
| args[0] +
|
| (this.useColors ? '%c ' : ' ') +
|
| '+' + module.exports.humanize(this.diff);
|
|
|
| if (!this.useColors) {
|
| return;
|
| }
|
|
|
| const c = 'color: ' + this.color;
|
| args.splice(1, 0, c, 'color: inherit');
|
|
|
|
|
|
|
|
|
| let index = 0;
|
| let lastC = 0;
|
| args[0].replace(/%[a-zA-Z%]/g, match => {
|
| if (match === '%%') {
|
| return;
|
| }
|
| index++;
|
| if (match === '%c') {
|
|
|
|
|
| lastC = index;
|
| }
|
| });
|
|
|
| args.splice(lastC, 0, c);
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| exports.log = console.debug || console.log || (() => {});
|
|
|
| |
| |
| |
| |
| |
|
|
| function save(namespaces) {
|
| try {
|
| if (namespaces) {
|
| exports.storage.setItem('debug', namespaces);
|
| } else {
|
| exports.storage.removeItem('debug');
|
| }
|
| } catch (error) {
|
|
|
|
|
| }
|
| }
|
|
|
| |
| |
| |
| |
| |
|
|
| function load() {
|
| let r;
|
| try {
|
| r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;
|
| } catch (error) {
|
|
|
|
|
| }
|
|
|
|
|
| if (!r && typeof process !== 'undefined' && 'env' in process) {
|
| r = process.env.DEBUG;
|
| }
|
|
|
| return r;
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| function localstorage() {
|
| try {
|
|
|
|
|
| return localStorage;
|
| } catch (error) {
|
|
|
|
|
| }
|
| }
|
|
|
| module.exports = require('./common')(exports);
|
|
|
| const {formatters} = module.exports;
|
|
|
| |
| |
|
|
|
|
| formatters.j = function (v) {
|
| try {
|
| return JSON.stringify(v);
|
| } catch (error) {
|
| return '[UnexpectedJSONParseError]: ' + error.message;
|
| }
|
| };
|
|
|