Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

probe.gl

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

probe.gl - npm Package Compare versions

Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6

dist/lib/stats.js

2

bench.js

@@ -0,1 +1,3 @@

// This file enables: import 'probe.gl/bench'.
// Note: Must be published using package.json "files" field
module.exports = require('./dist/bench');
CHANGELOG
v1.0.0-alpha.6
- Experimental image utils
v1.0.0-alpha.5

@@ -4,0 +7,0 @@ - fix console logging

18

dist/bench/bench.js

@@ -167,15 +167,7 @@ 'use strict';

value: function onSuiteComplete() {
var localStorage = void 0;
try {
localStorage = new _localStorage2.default();
} catch (error) {
// Local Storage not available
}
if (localStorage) {
var saved = localStorage.getObject(this.id);
var current = this.updateTable(this.table, saved);
localStorage.setObject(this.id, current);
console.table(current);
}
var localStorage = new _localStorage2.default({ id: this.id });
var saved = localStorage.getConfiguration();
var current = this.updateTable(this.table, saved);
localStorage.updateConfiguration(current);
console.table(current);
}

@@ -182,0 +174,0 @@ }, {

@@ -6,3 +6,3 @@ 'use strict';

});
exports.experimental = exports.COLOR = exports.Log = exports.VERSION = undefined;
exports.experimental = exports.Stats = exports.COLOR = exports.Log = exports.VERSION = undefined;

@@ -36,2 +36,11 @@ var _globals = require('./lib/utils/globals');

var _stats = require('./lib/stats');
Object.defineProperty(exports, 'Stats', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_stats).default;
}
});
require('./init');

@@ -43,17 +52,8 @@

// export {default as Stats} from './lib/stats';
// DOM logging
// Experimental exports
var experimental = exports.experimental = {
enableDOMLogging: _logToDom.enableDOMLogging
};
// // Make Probe available as global variable for debugging purposes
// // TODO - convenient but can be a concern for "purists"
// export {default as Probe} from './probe';
// import Probe from './probe';
// import {global} from './lib/utils/globals';
// global.Probe = Probe;
//# sourceMappingURL=index.js.map

@@ -35,2 +35,6 @@ 'use strict';

var _localStorage = require('./utils/local-storage');
var _localStorage2 = _interopRequireDefault(_localStorage);
var _timestamp = require('./utils/timestamp');

@@ -42,6 +46,2 @@

var _localStorage = require('./utils/local-storage');
var _localStorage2 = _interopRequireDefault(_localStorage);
var _autobind = require('./utils/autobind');

@@ -64,3 +64,3 @@

var originalConsole = {
debug: console.debug,
debug: _globals.isBrowser ? console.debug || console.log : console.log,
log: console.log,

@@ -136,4 +136,3 @@ info: console.info,

var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
id = _ref.id,
probe = _ref.probe;
id = _ref.id;

@@ -143,16 +142,11 @@ _classCallCheck(this, Log);

this.id = id;
this._probe = probe;
this._getLogFuncStore = [];
this._startTs = (0, _timestamp.getTimestamp)();
this._deltaTs = (0, _timestamp.getTimestamp)();
this._lastLogFunction = null;
// TODO - fix support from throttling groups
this.LOG_THROTTLE_TIMEOUT = 0; // Time before throttled messages are logged again
this._storage = new _localStorage2.default('probe-' + this.id, DEFAULT_SETTINGS);
this.userData = {};
this.userData = {};
this.timeStamp(this.id + ' started');
this._storage = new _localStorage2.default('probe-' + this.id, DEFAULT_SETTINGS);
(0, _autobind.autobind)(this);

@@ -241,25 +235,15 @@ Object.seal(this);

value: function probe(priority, message) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
args[_key3 - 2] = arguments[_key3];
}
return this._getLogFunction({ priority: priority, message: message, opts: opts, method: originalConsole.log });
return this._getLogFunction({
priority: priority,
message: message,
args: args,
method: originalConsole.log
});
}
// externalProbe(priority, message, timeStart, timeSpent, meta = {}) {
// if (this._probe._shouldLog(priority)) {
// // External probes are expected to provide epoch getTimestamps
// const total = timeStart - this._probe._startEpochTs;
// const delta = timeSpent;
// const logRow = this._probe._createLogRow({
// priority, name: message, total, delta, indent: ' '
// }, meta);
// this._getLogFuncStore.push(logRow);
// }
// return this;
// }
// Log a normal message
// info(priority, message, ...args) {
// return this._getLogFunction({
// priority, message, args,
// method: console.info
// });
// Log a debug message

@@ -269,4 +253,4 @@ }, {

value: function log(priority, message) {
for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
args[_key3 - 2] = arguments[_key3];
for (var _len4 = arguments.length, args = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
args[_key4 - 2] = arguments[_key4];
}

@@ -278,6 +262,21 @@

args: args,
method: originalConsole.debug || originalConsole.info
method: originalConsole.debug
});
}
// Log a normal message
}, {
key: 'info',
value: function info(priority, message) {
for (var _len5 = arguments.length, args = Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) {
args[_key5 - 2] = arguments[_key5];
}
return this._getLogFunction({
priority: priority, message: message, args: args,
method: console.info
});
}
// Log a normal message, but only once, no console flooding

@@ -288,4 +287,4 @@

value: function once(priority, message) {
for (var _len4 = arguments.length, args = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
args[_key4 - 2] = arguments[_key4];
for (var _len6 = arguments.length, args = Array(_len6 > 2 ? _len6 - 2 : 0), _key6 = 2; _key6 < _len6; _key6++) {
args[_key6 - 2] = arguments[_key6];
}

@@ -301,6 +300,9 @@

}
// Logs an object as a table
}, {
key: 'table',
value: function table(priority, _table, columns) {
if (priority <= this.priority && _table) {
if (_table) {
var tag = getTableHeader(_table);

@@ -312,3 +314,3 @@ return this._getLogFunction({

tag: tag,
method: console.table
method: console.table || noop
});

@@ -319,7 +321,2 @@ }

// Logs an object as a table
// table(priority, table) {
// const opts = this._getOpts({priority});
// }
// logs an image under Chrome

@@ -384,21 +381,18 @@

key: 'timeStamp',
value: function timeStamp() {}
// timeStamp(priority, message) {
// return this._getLogFunction({
// priority,
// message,
// method: console.timeStamp
// });
// }
// TODO - groups need some support under Node.js
value: function timeStamp(priority, message) {
return this._getLogFunction({
priority: priority,
message: message,
method: console.timeStamp || noop
});
}
}, {
key: 'group',
value: function group(priority, message) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _opts$collapsed = opts.collapsed,
collapsed = _opts$collapsed === undefined ? false : _opts$collapsed;
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { collapsed: false };
opts = this._parseArguments({ priority: priority, message: message, opts: opts });
var _opts = opts,
collapsed = _opts.collapsed;
return this._getLogFunction({

@@ -412,11 +406,37 @@ priority: priority,

}, {
key: 'groupCollapsed',
value: function groupCollapsed(priority, message) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return this.group(priority, message, Object.assign({}, opts, { collapsed: true }));
}
}, {
key: 'groupEnd',
value: function groupEnd(priority, message) {
value: function groupEnd(priority) {
return this._getLogFunction({
priority: priority,
message: message,
message: '',
method: console.groupEnd || noop
});
}
// EXPERIMENTAL
}, {
key: 'withGroup',
value: function withGroup(priority, message, func) {
var opts = this._parseArguments({
priority: priority,
message: message
});
this.group(opts);
try {
func();
} finally {
this.groupEnd(opts.message);
}
}
}, {
key: 'trace',

@@ -429,21 +449,33 @@ value: function trace() {

// Private Methods
// PRIVATE METHODS
}, {
key: '_shouldLog',
value: function _shouldLog(priority) {
(0, _assert2.default)(Number.isFinite(priority), 'log priority must be a number');
return this.priority >= priority;
}
}, {
key: '_getElapsedTime',
value: function _getElapsedTime() {
var total = this.getTotal();
var delta = this.getDelta();
// reset delta timer
this._deltaTs = (0, _timestamp.getTimestamp)();
return { total: total, delta: delta };
}
}, {
key: '_getLogFunction',
value: function _getLogFunction(opts) {
var _opts = opts,
method = _opts.method;
var _opts2 = opts,
method = _opts2.method;
opts = this._getOpts(opts);
opts = this._parseArguments(opts);
// Verify that last log function was actually called
this._checkLastLogFunction();
(0, _assert2.default)(method);
if (this._shouldLog(opts.priority)) {
var _opts2 = opts,
message = _opts2.message;
var _opts3 = opts,
message = _opts3.message;

@@ -460,5 +492,6 @@ var tag = opts.tag || opts.message;

if (opts.nothrottle || !throttle(tag, this.LOG_THROTTLE_TIMEOUT)) {
return noop;
}
// TODO - Make throttling work with groups
// if (opts.nothrottle || !throttle(tag, this.LOG_THROTTLE_TIMEOUT)) {
// return noop;
// }

@@ -468,13 +501,17 @@ message = (0, _color.addColor)(message, opts.color, opts.background);

// Bind console function so that it can be called after being returned
this._lastLogFunction = method.bind.apply(method, [console, message].concat(_toConsumableArray(opts.args)));
return method.bind.apply(method, [console, message].concat(_toConsumableArray(opts.args)));
}
// Catch missing `()()`
var logFunction = this._lastLogFunction || noop;
this._lastLogFunction = null;
return logFunction;
return noop;
}
// "Normalizes" the various argument patterns into an object with known types
// - log(priority, message, args) => {priority, message, args}
// - log(message, args) => {priority: 0, message, args}
// - log({priority, ...}, message, args) => {priority, message, args}
// - log({priority, message, args}) => {priority, message, args}
}, {
key: '_getOpts',
value: function _getOpts(_ref3) {
key: '_parseArguments',
value: function _parseArguments(_ref3) {
var priority = _ref3.priority,

@@ -487,3 +524,3 @@ message = _ref3.message,

var newOptions = this._getBaseOpts({ priority: priority, message: message, args: args });
var newOpts = this._normalizeArguments({ priority: priority, message: message, args: args });

@@ -494,4 +531,4 @@ var _getElapsedTime2 = this._getElapsedTime(),

return Object.assign(newOptions, opts, {
message: typeof newOptions === 'string' ? this.id + ': ' + newOptions.message : newOptions.message,
return Object.assign(newOpts, opts, {
message: typeof newOpts === 'string' ? this.id + ': ' + newOpts.message : newOpts.message,
delta: delta,

@@ -502,11 +539,7 @@ total: total

// "Normalizes" the various argument patterns into an object
// - log(priority, message, args) => {priority, message, args}
// - log(message, args) => {priority: 0, message, args}
// - log({priority, ...}, message, args) => {priority, message, args}
// - log({priority, message, args}) => {priority, message, args}
// helper for _parseArguments
}, {
key: '_getBaseOpts',
value: function _getBaseOpts(_ref4) {
key: '_normalizeArguments',
value: function _normalizeArguments(_ref4) {
var priority = _ref4.priority,

@@ -517,3 +550,3 @@ message = _ref4.message,

var newOptions = null;
var newOpts = null;

@@ -523,3 +556,3 @@ switch (typeof priority === 'undefined' ? 'undefined' : _typeof(priority)) {

(0, _assert2.default)(priority >= 0);
newOptions = { priority: priority, message: message, args: args };
newOpts = { priority: priority, message: message, args: args };
break;

@@ -532,3 +565,3 @@

}
newOptions = { priority: 0, message: priority, args: args };
newOpts = { priority: 0, message: priority, args: args };
break;

@@ -538,74 +571,23 @@

var opts = priority;
newOptions = Object.assign({ priority: 0, message: message, args: args }, opts);
newOpts = Object.assign({ priority: 0, message: message, args: args }, opts);
break;
default:
newOptions = { priority: 0, message: message, args: args };
newOpts = { priority: 0, message: message, args: args };
break;
}
(0, _assert2.default)(Number.isFinite(newOptions.priority)); // 'log priority must be a number'
(0, _assert2.default)(Number.isFinite(newOpts.priority)); // 'log priority must be a number'
// Resolve strings
if (typeof newOptions.message === 'function') {
newOptions.message = this._shouldLog(newOptions.priority) ? newOptions.message() : 'low priority log';
// Resolve functions into strings by calling them
if (typeof newOpts.message === 'function') {
newOpts.message = this._shouldLog(newOpts.priority) ? newOpts.message() : '';
}
// 'log message must be a string' or object
(0, _assert2.default)(typeof newOptions.message === 'string' || _typeof(newOptions.message) === 'object');
(0, _assert2.default)(typeof newOpts.message === 'string' || _typeof(newOpts.message) === 'object');
return newOptions;
return newOpts;
}
}, {
key: '_shouldLog',
value: function _shouldLog(priority) {
(0, _assert2.default)(Number.isFinite(priority), 'log priority must be a number');
return this.priority >= priority;
}
// Verify that last log function was actually called
}, {
key: '_checkLastLogFunction',
value: function _checkLastLogFunction() {
if (this._lastLogFunction) {
// console.warn('last log function not called, calling now');
// this._lastLogFunction();
// this._lastLogFunction = null;
}
}
}, {
key: '_getElapsedTime',
value: function _getElapsedTime() {
var total = this.getTotal();
var delta = this.getDelta();
// reset delta timer
this._deltaTs = (0, _timestamp.getTimestamp)();
return { total: total, delta: delta };
}
// _print({collapsed}) {
// if (this._probe._shouldLog(0)) {
// const groupTotal = formatTime(this.getTotal());
// const probeTotal = formatTime(this._probe.getTotal());
// const header =
// `${leftPad(probeTotal)} ${leftPad(groupTotal)} ${this.id}`;
// if (collapsed) {
// logger.groupCollapsed(header);
// } else {
// logger.group(header);
// }
// for (const logRow of this._getLogFuncStore) {
// const line = this._probe._formatLogRowForConsole(logRow);
// logger.debug(line);
// }
// logger.groupEnd();
// }
// return this;
// }
}, {
key: 'priority',

@@ -612,0 +594,0 @@ set: function set(newPriority) {

@@ -24,3 +24,3 @@ 'use strict';

/* global __VERSION__ */
var VERSION = typeof '1.0.0-alpha.5' !== 'undefined' ? '1.0.0-alpha.5' : 'untranspiled source';
var VERSION = typeof '1.0.0-alpha.6' !== 'undefined' ? '1.0.0-alpha.6' : 'untranspiled source';

@@ -27,0 +27,0 @@ exports.window = window_;

@@ -56,3 +56,3 @@ 'use strict';

Object.assign(this.config, defaultSettings);
this.loadConfiguration();
this._loadConfiguration();
}

@@ -66,2 +66,8 @@

}, {
key: 'setConfiguration',
value: function setConfiguration(configuration) {
this.config = {};
return this.updateConfiguration(configuration);
}
}, {
key: 'updateConfiguration',

@@ -80,4 +86,4 @@ value: function updateConfiguration(configuration) {

}, {
key: 'loadConfiguration',
value: function loadConfiguration() {
key: '_loadConfiguration',
value: function _loadConfiguration() {
var configuration = {};

@@ -84,0 +90,0 @@ if (this.storage) {

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "1.0.0-alpha.5",
"version": "1.0.0-alpha.6",
"keywords": [

@@ -22,3 +22,4 @@ "javascript",

"bench.js",
"test.js"
"test.js",
"test-utils.js"
],

@@ -36,9 +37,8 @@ "scripts": {

"publish-beta": "npm run test && npm run test-dist && npm publish --tag beta",
"test": "npm run lint && npm run test-node && npm run build",
"test-fast": "npm run test-node | faucet",
"test": "node test/start.js test && node test/start.js log && npm run build",
"test-fast": "node test/start.js test | tap-diff",
"test-dist": "node test/start.js test-dist",
"test-cover": "NODE_ENV=test tape -r babel-register test/node.js && nyc report",
"test-node": "node test/test-node.js",
"test-dist": "node test/test-node-dist.js",
"bench": "node test/start.js bench",
"test-browser": "webpack-dev-server --env.test --progress --hot --open",
"bench-node": "node test/bench-node.js",
"bench-browser": "webpack-dev-server --env.bench --progress --hot --open"

@@ -64,9 +64,10 @@ },

"eslint-config-uber-es2015": "^3.0.0",
"faucet": "0.0.1",
"module-alias": "^2.0.0",
"nyc": "^10.2.0",
"pre-commit": "^1.2.2",
"puppeteer": "^1.1.1",
"reify": "^0.4.4",
"source-map-loader": "^0.2.1",
"tap-browser-color": "^0.1.2",
"tap-diff": "^0.1.1",
"tape": "^4.5.1",

@@ -73,0 +74,0 @@ "tape-catch": "^1.0.4",

@@ -16,3 +16,3 @@ <p align="right">

<h1 align="center">probe.gl | <a href="https://uber-web.github.io/probe.gl">Docs</a></h1>
<h1 align="center">probe.gl | <a href="https://uber-web.github.io/probe.gl/#/documentation/overview">Docs</a></h1>

@@ -19,0 +19,0 @@ probe.gl lets you instrument your JavaScript applications to get timings in browser console or in node, and much more.

@@ -118,15 +118,7 @@ /* eslint-disable no-console */

onSuiteComplete() {
let localStorage;
try {
localStorage = new LocalStorage();
} catch (error) {
// Local Storage not available
}
if (localStorage) {
const saved = localStorage.getObject(this.id);
const current = this.updateTable(this.table, saved);
localStorage.setObject(this.id, current);
console.table(current);
}
const localStorage = new LocalStorage({id: this.id});
const saved = localStorage.getConfiguration();
const current = this.updateTable(this.table, saved);
localStorage.updateConfiguration(current);
console.table(current);
}

@@ -133,0 +125,0 @@

@@ -8,15 +8,9 @@ import './init';

// export {default as Stats} from './lib/stats';
export {default as Stats} from './lib/stats';
// Experimental exports
// DOM logging
import {enableDOMLogging} from './lib/utils/log-to-dom';
export const experimental = {
enableDOMLogging
};
// // Make Probe available as global variable for debugging purposes
// // TODO - convenient but can be a concern for "purists"
// export {default as Probe} from './probe';
// import Probe from './probe';
// import {global} from './lib/utils/globals';
// global.Probe = Probe;

@@ -24,7 +24,8 @@ // Copyright (c) 2017 Uber Technologies, Inc.

import {VERSION} from './utils/globals';
import LocalStorage from './utils/local-storage';
import {getTimestamp} from './utils/timestamp';
import {formatImage} from './utils/formatters';
import {addColor} from './utils/color';
import LocalStorage from './utils/local-storage';
import {autobind} from './utils/autobind';
import {isBrowser} from './utils/globals';
import assert from 'assert';

@@ -37,3 +38,3 @@

const originalConsole = {
debug: console.debug,
debug: isBrowser ? console.debug || console.log : console.log,
log: console.log,

@@ -108,18 +109,13 @@ info: console.info,

constructor({id, probe} = {}) {
constructor({id} = {}) {
this.id = id;
this._probe = probe;
this._getLogFuncStore = [];
this._startTs = getTimestamp();
this._deltaTs = getTimestamp();
this._lastLogFunction = null;
// TODO - fix support from throttling groups
this.LOG_THROTTLE_TIMEOUT = 0; // Time before throttled messages are logged again
this._storage = new LocalStorage(`probe-${this.id}`, DEFAULT_SETTINGS);
this.userData = {};
this.userData = {};
this.timeStamp(`${this.id} started`);
this._storage = new LocalStorage(`probe-${this.id}`, DEFAULT_SETTINGS);
autobind(this);

@@ -191,25 +187,12 @@ Object.seal(this);

// Log to a group
probe(priority, message, opts = {}) {
return this._getLogFunction({priority, message, opts, method: originalConsole.log});
probe(priority, message, ...args) {
return this._getLogFunction({
priority,
message,
args,
method: originalConsole.log
});
}
// externalProbe(priority, message, timeStart, timeSpent, meta = {}) {
// if (this._probe._shouldLog(priority)) {
// // External probes are expected to provide epoch getTimestamps
// const total = timeStart - this._probe._startEpochTs;
// const delta = timeSpent;
// const logRow = this._probe._createLogRow({
// priority, name: message, total, delta, indent: ' '
// }, meta);
// this._getLogFuncStore.push(logRow);
// }
// return this;
// }
// Log a normal message
// info(priority, message, ...args) {
// return this._getLogFunction({
// priority, message, args,
// method: console.info
// });
// Log a debug message
log(priority, message, ...args) {

@@ -220,6 +203,14 @@ return this._getLogFunction({

args,
method: originalConsole.debug || originalConsole.info
method: originalConsole.debug
});
}
// Log a normal message
info(priority, message, ...args) {
return this._getLogFunction({
priority, message, args,
method: console.info
});
}
// Log a normal message, but only once, no console flooding

@@ -236,4 +227,5 @@ once(priority, message, ...args) {

// Logs an object as a table
table(priority, table, columns) {
if (priority <= this.priority && table) {
if (table) {
const tag = getTableHeader(table);

@@ -245,3 +237,3 @@ return this._getLogFunction({

tag,
method: console.table
method: console.table || noop
});

@@ -252,7 +244,2 @@ }

// Logs an object as a table
// table(priority, table) {
// const opts = this._getOpts({priority});
// }
// logs an image under Chrome

@@ -299,15 +286,13 @@ image({priority, image, message = '', scale = 1}) {

timeStamp() {}
timeStamp(priority, message) {
return this._getLogFunction({
priority,
message,
method: console.timeStamp || noop
});
}
// timeStamp(priority, message) {
// return this._getLogFunction({
// priority,
// message,
// method: console.timeStamp
// });
// }
// TODO - groups need some support under Node.js
group(priority, message, opts = {}) {
const {collapsed = false} = opts;
group(priority, message, opts = {collapsed: false}) {
opts = this._parseArguments({priority, message, opts});
const {collapsed} = opts;
return this._getLogFunction({

@@ -321,6 +306,10 @@ priority,

groupEnd(priority, message) {
groupCollapsed(priority, message, opts = {}) {
return this.group(priority, message, Object.assign({}, opts, {collapsed: true}));
}
groupEnd(priority) {
return this._getLogFunction({
priority,
message,
message: '',
method: console.groupEnd || noop

@@ -330,2 +319,19 @@ });

// EXPERIMENTAL
withGroup(priority, message, func) {
const opts = this._parseArguments({
priority,
message
});
this.group(opts);
try {
func();
} finally {
this.groupEnd(opts.message);
}
}
trace() {

@@ -337,12 +343,22 @@ if (console.trace) {

// Private Methods
// PRIVATE METHODS
_shouldLog(priority) {
assert(Number.isFinite(priority), 'log priority must be a number');
return this.priority >= priority;
}
_getElapsedTime() {
const total = this.getTotal();
const delta = this.getDelta();
// reset delta timer
this._deltaTs = getTimestamp();
return {total, delta};
}
_getLogFunction(opts) {
const {method} = opts;
opts = this._getOpts(opts);
opts = this._parseArguments(opts);
// Verify that last log function was actually called
this._checkLastLogFunction();
assert(method);

@@ -362,5 +378,6 @@

if (opts.nothrottle || !throttle(tag, this.LOG_THROTTLE_TIMEOUT)) {
return noop;
}
// TODO - Make throttling work with groups
// if (opts.nothrottle || !throttle(tag, this.LOG_THROTTLE_TIMEOUT)) {
// return noop;
// }

@@ -370,20 +387,20 @@ message = addColor(message, opts.color, opts.background);

// Bind console function so that it can be called after being returned
this._lastLogFunction = method.bind(console, message, ...opts.args);
return method.bind(console, message, ...opts.args);
}
// Catch missing `()()`
const logFunction = this._lastLogFunction || noop;
this._lastLogFunction = null;
return logFunction;
return noop;
}
_getOpts({priority, message, args = [], opts = {}}) {
const newOptions = this._getBaseOpts({priority, message, args});
// "Normalizes" the various argument patterns into an object with known types
// - log(priority, message, args) => {priority, message, args}
// - log(message, args) => {priority: 0, message, args}
// - log({priority, ...}, message, args) => {priority, message, args}
// - log({priority, message, args}) => {priority, message, args}
_parseArguments({priority, message, args = [], opts = {}}) {
const newOpts = this._normalizeArguments({priority, message, args});
const {delta, total} = this._getElapsedTime();
return Object.assign(newOptions, opts, {
message: typeof newOptions === 'string' ?
`${this.id}: ${newOptions.message}` :
newOptions.message,
return Object.assign(newOpts, opts, {
message: typeof newOpts === 'string' ? `${this.id}: ${newOpts.message}` : newOpts.message,
delta,

@@ -394,9 +411,5 @@ total

// "Normalizes" the various argument patterns into an object
// - log(priority, message, args) => {priority, message, args}
// - log(message, args) => {priority: 0, message, args}
// - log({priority, ...}, message, args) => {priority, message, args}
// - log({priority, message, args}) => {priority, message, args}
_getBaseOpts({priority, message, args = []}) {
let newOptions = null;
// helper for _parseArguments
_normalizeArguments({priority, message, args = []}) {
let newOpts = null;

@@ -406,3 +419,3 @@ switch (typeof priority) {

assert(priority >= 0);
newOptions = {priority, message, args};
newOpts = {priority, message, args};
break;

@@ -415,3 +428,3 @@

}
newOptions = {priority: 0, message: priority, args};
newOpts = {priority: 0, message: priority, args};
break;

@@ -421,71 +434,24 @@

const opts = priority;
newOptions = Object.assign({priority: 0, message, args}, opts);
newOpts = Object.assign({priority: 0, message, args}, opts);
break;
default:
newOptions = {priority: 0, message, args};
newOpts = {priority: 0, message, args};
break;
}
assert(Number.isFinite(newOptions.priority)); // 'log priority must be a number'
assert(Number.isFinite(newOpts.priority)); // 'log priority must be a number'
// Resolve strings
if (typeof newOptions.message === 'function') {
newOptions.message = this._shouldLog(newOptions.priority) ?
newOptions.message() :
'low priority log';
// Resolve functions into strings by calling them
if (typeof newOpts.message === 'function') {
newOpts.message = this._shouldLog(newOpts.priority) ? newOpts.message() : '';
}
// 'log message must be a string' or object
assert(typeof newOptions.message === 'string' || typeof newOptions.message === 'object');
assert(typeof newOpts.message === 'string' || typeof newOpts.message === 'object');
return newOptions;
return newOpts;
}
_shouldLog(priority) {
assert(Number.isFinite(priority), 'log priority must be a number');
return this.priority >= priority;
}
// Verify that last log function was actually called
_checkLastLogFunction() {
if (this._lastLogFunction) {
// console.warn('last log function not called, calling now');
// this._lastLogFunction();
// this._lastLogFunction = null;
}
}
_getElapsedTime() {
const total = this.getTotal();
const delta = this.getDelta();
// reset delta timer
this._deltaTs = getTimestamp();
return {total, delta};
}
// _print({collapsed}) {
// if (this._probe._shouldLog(0)) {
// const groupTotal = formatTime(this.getTotal());
// const probeTotal = formatTime(this._probe.getTotal());
// const header =
// `${leftPad(probeTotal)} ${leftPad(groupTotal)} ${this.id}`;
// if (collapsed) {
// logger.groupCollapsed(header);
// } else {
// logger.group(header);
// }
// for (const logRow of this._getLogFuncStore) {
// const line = this._probe._formatLogRowForConsole(logRow);
// logger.debug(line);
// }
// logger.groupEnd();
// }
// return this;
// }
}
Log.VERSION = VERSION;

@@ -41,3 +41,3 @@ // Copyright (c) 2017 Uber Technologies, Inc.

Object.assign(this.config, defaultSettings);
this.loadConfiguration();
this._loadConfiguration();
}

@@ -49,2 +49,7 @@

setConfiguration(configuration) {
this.config = {};
return this.updateConfiguration(configuration);
}
updateConfiguration(configuration) {

@@ -60,3 +65,3 @@ Object.assign(this.config, configuration);

// Get config from persistent store, if available
loadConfiguration() {
_loadConfiguration() {
let configuration = {};

@@ -63,0 +68,0 @@ if (this.storage) {

@@ -1,1 +0,4 @@

module.exports = require('./dist/test');
// This file enables: import 'probe.gl/test'.
// Note: Must be published using package.json "files" field
console.warn("import 'probe.gl/test' is deprecated, use import 'probe.gl/test-utils'"); // eslint-disable-line
module.exports = require('./dist/test-utils');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc