Comparing version 1.0.0-alpha.7 to 1.0.0-alpha.8
CHANGELOG | ||
v1.0.0-alpha.8 | ||
- default log export | ||
- `Log.probe` | ||
- `Stats` class improvements | ||
v1.0.0-alpha.7 | ||
@@ -4,0 +9,0 @@ - probe timings |
@@ -48,2 +48,4 @@ 'use strict'; | ||
var _log2 = _interopRequireDefault(_log); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -57,2 +59,5 @@ | ||
}; | ||
// Default export is a log | ||
exports.default = new _log2.default({ id: 'probe.gl' }); | ||
//# sourceMappingURL=index.js.map |
@@ -78,6 +78,7 @@ 'use strict'; | ||
/* | ||
function throttle(tag, timeout) { | ||
var prevTime = cache[tag]; | ||
var time = Date.now(); | ||
if (!prevTime || time - prevTime > timeout) { | ||
const prevTime = cache[tag]; | ||
const time = Date.now(); | ||
if (!prevTime || (time - prevTime > timeout)) { | ||
cache[tag] = time; | ||
@@ -89,25 +90,2 @@ return true; | ||
function getTableHeader(table) { | ||
for (var key in table) { | ||
for (var title in table[key]) { | ||
return title || 'untitled'; | ||
} | ||
} | ||
return 'empty'; | ||
} | ||
/* CODE from deck.gl logger, delete when replicated | ||
function formatArgs(firstArg, ...args) { | ||
if (typeof firstArg === 'function') { | ||
firstArg = firstArg(); | ||
} | ||
if (typeof firstArg === 'string') { | ||
args.unshift(`deck.gl ${firstArg}`); | ||
} else { | ||
args.unshift(firstArg); | ||
args.unshift('deck.gl'); | ||
} | ||
return args; | ||
} | ||
// Assertions don't generate standard exceptions and don't print nicely | ||
@@ -130,4 +108,13 @@ function checkForAssertionErrors(args) { | ||
// A simple console wrapper | ||
function getTableHeader(table) { | ||
for (var key in table) { | ||
for (var title in table[key]) { | ||
return title || 'untitled'; | ||
} | ||
} | ||
return 'empty'; | ||
} | ||
// A console wrapper | ||
var Log = function () { | ||
@@ -141,2 +128,3 @@ function Log() { | ||
this.id = id; | ||
this.VERSION = _globals.VERSION; | ||
this._startTs = (0, _timestamp.getTimestamp)(); | ||
@@ -146,3 +134,3 @@ this._deltaTs = (0, _timestamp.getTimestamp)(); | ||
this.LOG_THROTTLE_TIMEOUT = 0; // Time before throttled messages are logged again | ||
this._storage = new _localStorage2.default('probe-' + this.id, DEFAULT_SETTINGS); | ||
this._storage = new _localStorage2.default('__probe-' + this.id + '__', DEFAULT_SETTINGS); | ||
this.userData = {}; | ||
@@ -157,20 +145,21 @@ | ||
_createClass(Log, [{ | ||
key: 'enable', | ||
value: function enable() { | ||
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
this._storage.updateConfiguration({ enabled: enabled }); | ||
return this; | ||
key: 'isEnabled', | ||
value: function isEnabled() { | ||
return this._storage.config.enabled; | ||
} | ||
}, { | ||
key: 'setLevel', | ||
value: function setLevel(level) { | ||
this._storage.updateConfiguration({ priority: level }); | ||
return this; | ||
key: 'getPriority', | ||
value: function getPriority() { | ||
return this._storage.config.priority; | ||
} | ||
}, { | ||
key: 'getTotal', | ||
key: 'getLevel', | ||
value: function getLevel() { | ||
return this._storage.config.priority; | ||
} | ||
// @return {Number} milliseconds, with fractions | ||
// @return {Number} milliseconds, with fractions | ||
}, { | ||
key: 'getTotal', | ||
value: function getTotal() { | ||
@@ -188,2 +177,19 @@ return Number(((0, _timestamp.getTimestamp)() - this._startTs).toPrecision(10)); | ||
// Configure | ||
}, { | ||
key: 'enable', | ||
value: function enable() { | ||
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
this._storage.updateConfiguration({ enabled: enabled }); | ||
return this; | ||
} | ||
}, { | ||
key: 'setLevel', | ||
value: function setLevel(level) { | ||
this._storage.updateConfiguration({ priority: level }); | ||
return this; | ||
} | ||
// Unconditional logging | ||
@@ -330,3 +336,3 @@ | ||
if (priority > this.priority) { | ||
if (priority > this.getPriority()) { | ||
return noop; | ||
@@ -450,3 +456,3 @@ } | ||
(0, _assert2.default)(Number.isFinite(priority), 'log priority must be a number'); | ||
return this.priority >= priority; | ||
return priority === 0 || this.isEnabled() && this.getPriority() >= priority; | ||
} | ||
@@ -605,7 +611,2 @@ }, { | ||
} | ||
}, { | ||
key: 'enabled', | ||
get: function get() { | ||
return this._storage.config.enabled; | ||
} | ||
}]); | ||
@@ -612,0 +613,0 @@ |
@@ -24,14 +24,4 @@ 'use strict'; | ||
this.id = id; | ||
this.time = (0, _timestamp.getTimestamp)(); | ||
this.counters = {}; | ||
// this.context = {}; | ||
// this.count = 0; | ||
// this.timer = null; | ||
// this._time = 0; | ||
// this.startTime = 0; | ||
// this.total = 0; | ||
// this.average = 0; | ||
Object.seal(this); | ||
@@ -116,4 +106,4 @@ } | ||
}, { | ||
key: 'oneSecondPassed', | ||
value: function oneSecondPassed() { | ||
key: 'hasTimeElapsed', | ||
value: function hasTimeElapsed() { | ||
var deltaTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000; | ||
@@ -169,4 +159,17 @@ | ||
} | ||
}, { | ||
key: 'getCount', | ||
value: function getCount(name) { | ||
var counter = this._getCounter(name); | ||
return counter.count; | ||
} | ||
}, { | ||
key: 'getFPS', | ||
value: function getFPS(name) { | ||
var counter = this._getCounter(name); | ||
var deltaTime = ((0, _timestamp.getTimestamp)() - this.time) / 1000; | ||
return Math.round(counter.count / deltaTime); | ||
} | ||
// EXPERIMENTAL METHODS | ||
// DEPRECATED METHODS | ||
@@ -178,3 +181,10 @@ }, { | ||
} | ||
}, { | ||
key: 'oneSecondPassed', | ||
value: function oneSecondPassed() { | ||
var deltaTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000; | ||
return this.hasTimeElapsed(deltaTime); | ||
} | ||
// PRIVATE METHODS | ||
@@ -207,43 +217,2 @@ | ||
} | ||
/* | ||
startIdleFPSTracking() { | ||
this.time = getTimestamp(); | ||
this.count = 0; | ||
this.context = context; | ||
this.initCounter({name: 'idle-fps'}); | ||
this.resetCounters(); | ||
// Register timer | ||
this.timer = window.requestAnimationFrame(this._onFPSTimer.bind(this)); | ||
} | ||
stop() { | ||
window.cancelAnimationFrame(this.timer); | ||
this.timer = null; | ||
} | ||
_onFPSTimer() { | ||
const now = getTimestamp(); | ||
const elapsedTime = (now - this.time) / 1000; | ||
// Check if we should start counting | ||
this.bumpCounter({name: 'idle-fps'}); | ||
if (elapsedTime >= 1.0) { | ||
this._reportFPS(elapsedTime); | ||
this.resetCounters(); | ||
this.time = now; | ||
this.count++; | ||
} | ||
// Register another callback | ||
this.timer = window.requestAnimationFrame(this._updateFPSTimer.bind(this)); | ||
} | ||
_reportFPS(elapsedTime) { | ||
const fpsValues = {count: this.count, context: this.context}; | ||
for (const key in this.counters) { | ||
const counter = this.counters[key]; | ||
let fps = Math.round(counter.count / elapsedTime); | ||
fps = Math.min(fps, MAX_FPS); | ||
fpsValues[key] = fps; | ||
} | ||
this.reportFPS(fpsValues); | ||
} | ||
*/ | ||
}]); | ||
@@ -250,0 +219,0 @@ |
@@ -24,3 +24,3 @@ 'use strict'; | ||
/* global __VERSION__ */ | ||
var VERSION = typeof '1.0.0-alpha.7' !== 'undefined' ? '1.0.0-alpha.7' : 'untranspiled source'; | ||
var VERSION = typeof '1.0.0-alpha.8' !== 'undefined' ? '1.0.0-alpha.8' : 'untranspiled source'; | ||
@@ -27,0 +27,0 @@ exports.window = window_; |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-alpha.7", | ||
"version": "1.0.0-alpha.8", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "javascript", |
@@ -16,1 +16,5 @@ import './init'; | ||
}; | ||
// Default export is a log | ||
import {default as Log} from './lib/log'; | ||
export default new Log({id: 'probe.gl'}); |
@@ -53,2 +53,3 @@ // Copyright (c) 2017 Uber Technologies, Inc. | ||
/* | ||
function throttle(tag, timeout) { | ||
@@ -64,25 +65,2 @@ const prevTime = cache[tag]; | ||
function getTableHeader(table) { | ||
for (const key in table) { | ||
for (const title in table[key]) { | ||
return title || 'untitled'; | ||
} | ||
} | ||
return 'empty'; | ||
} | ||
/* CODE from deck.gl logger, delete when replicated | ||
function formatArgs(firstArg, ...args) { | ||
if (typeof firstArg === 'function') { | ||
firstArg = firstArg(); | ||
} | ||
if (typeof firstArg === 'string') { | ||
args.unshift(`deck.gl ${firstArg}`); | ||
} else { | ||
args.unshift(firstArg); | ||
args.unshift('deck.gl'); | ||
} | ||
return args; | ||
} | ||
// Assertions don't generate standard exceptions and don't print nicely | ||
@@ -105,4 +83,13 @@ function checkForAssertionErrors(args) { | ||
// A simple console wrapper | ||
function getTableHeader(table) { | ||
for (const key in table) { | ||
for (const title in table[key]) { | ||
return title || 'untitled'; | ||
} | ||
} | ||
return 'empty'; | ||
} | ||
// A console wrapper | ||
export default class Log { | ||
@@ -112,2 +99,3 @@ | ||
this.id = id; | ||
this.VERSION = VERSION; | ||
this._startTs = getTimestamp(); | ||
@@ -117,3 +105,3 @@ this._deltaTs = getTimestamp(); | ||
this.LOG_THROTTLE_TIMEOUT = 0; // Time before throttled messages are logged again | ||
this._storage = new LocalStorage(`probe-${this.id}`, DEFAULT_SETTINGS); | ||
this._storage = new LocalStorage(`__probe-${this.id}__`, DEFAULT_SETTINGS); | ||
this.userData = {}; | ||
@@ -127,22 +115,20 @@ | ||
enable(enabled = true) { | ||
this._storage.updateConfiguration({enabled}); | ||
set priority(newPriority) { | ||
this._storage.updateConfiguration({priority: newPriority}); | ||
return this; | ||
} | ||
setLevel(level) { | ||
this._storage.updateConfiguration({priority: level}); | ||
return this; | ||
get priority() { | ||
return this._storage.config.priority; | ||
} | ||
set priority(newPriority) { | ||
this._storage.updateConfiguration({priority: newPriority}); | ||
return this; | ||
isEnabled() { | ||
return this._storage.config.enabled; | ||
} | ||
get enabled() { | ||
return this._storage.config.enabled; | ||
getPriority() { | ||
return this._storage.config.priority; | ||
} | ||
get priority() { | ||
getLevel() { | ||
return this._storage.config.priority; | ||
@@ -161,2 +147,14 @@ } | ||
// Configure | ||
enable(enabled = true) { | ||
this._storage.updateConfiguration({enabled}); | ||
return this; | ||
} | ||
setLevel(level) { | ||
this._storage.updateConfiguration({priority: level}); | ||
return this; | ||
} | ||
// Unconditional logging | ||
@@ -247,3 +245,3 @@ | ||
image({priority, image, message = '', scale = 1}) { | ||
if (priority > this.priority) { | ||
if (priority > this.getPriority()) { | ||
return noop; | ||
@@ -345,3 +343,3 @@ } | ||
assert(Number.isFinite(priority), 'log priority must be a number'); | ||
return this.priority >= priority; | ||
return priority === 0 || (this.isEnabled() && this.getPriority() >= priority); | ||
} | ||
@@ -348,0 +346,0 @@ |
@@ -10,14 +10,4 @@ import {getTimestamp} from './utils/timestamp'; | ||
this.id = id; | ||
this.time = getTimestamp(); | ||
this.counters = {}; | ||
// this.context = {}; | ||
// this.count = 0; | ||
// this.timer = null; | ||
// this._time = 0; | ||
// this.startTime = 0; | ||
// this.total = 0; | ||
// this.average = 0; | ||
Object.seal(this); | ||
@@ -84,3 +74,3 @@ } | ||
oneSecondPassed(deltaTime = 1000) { | ||
hasTimeElapsed(deltaTime = 1000) { | ||
return (getTimestamp() - this.time) > 1000; | ||
@@ -127,4 +117,15 @@ } | ||
// EXPERIMENTAL METHODS | ||
getCount(name) { | ||
const counter = this._getCounter(name); | ||
return counter.count; | ||
} | ||
getFPS(name) { | ||
const counter = this._getCounter(name); | ||
const deltaTime = (getTimestamp() - this.time) / 1000; | ||
return Math.round(counter.count / deltaTime); | ||
} | ||
// DEPRECATED METHODS | ||
getTimeString() { | ||
@@ -134,2 +135,6 @@ return `${this.id}:${formatTime(this.time)}(${this.count})`; | ||
oneSecondPassed(deltaTime = 1000) { | ||
return this.hasTimeElapsed(deltaTime); | ||
} | ||
// PRIVATE METHODS | ||
@@ -159,51 +164,2 @@ | ||
} | ||
/* | ||
startIdleFPSTracking() { | ||
this.time = getTimestamp(); | ||
this.count = 0; | ||
this.context = context; | ||
this.initCounter({name: 'idle-fps'}); | ||
this.resetCounters(); | ||
// Register timer | ||
this.timer = window.requestAnimationFrame(this._onFPSTimer.bind(this)); | ||
} | ||
stop() { | ||
window.cancelAnimationFrame(this.timer); | ||
this.timer = null; | ||
} | ||
_onFPSTimer() { | ||
const now = getTimestamp(); | ||
const elapsedTime = (now - this.time) / 1000; | ||
// Check if we should start counting | ||
this.bumpCounter({name: 'idle-fps'}); | ||
if (elapsedTime >= 1.0) { | ||
this._reportFPS(elapsedTime); | ||
this.resetCounters(); | ||
this.time = now; | ||
this.count++; | ||
} | ||
// Register another callback | ||
this.timer = window.requestAnimationFrame(this._updateFPSTimer.bind(this)); | ||
} | ||
_reportFPS(elapsedTime) { | ||
const fpsValues = {count: this.count, context: this.context}; | ||
for (const key in this.counters) { | ||
const counter = this.counters[key]; | ||
let fps = Math.round(counter.count / elapsedTime); | ||
fps = Math.min(fps, MAX_FPS); | ||
fpsValues[key] = fps; | ||
} | ||
this.reportFPS(fpsValues); | ||
} | ||
*/ | ||
} |
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
248314
3811