|
12 | 12 | var d3 = require('d3');
|
13 | 13 |
|
14 | 14 | var lib = module.exports = {};
|
| 15 | +var config = require('../plot_api/plot_config'); |
15 | 16 |
|
16 | 17 | lib.nestedProperty = require('./nested_property');
|
17 | 18 | lib.isPlainObject = require('./is_plain_object');
|
@@ -100,25 +101,24 @@ lib.pauseEvent = function(e) {
|
100 | 101 |
|
101 | 102 | // set VERBOSE to true to get a lot more logging and tracing
|
102 | 103 | lib.VERBOSE = false;
|
103 |
| - |
104 |
| -// first markTime call will return time from page load |
105 |
| -lib.TIMER = new Date().getTime(); |
106 |
| - |
107 | 104 | // console.log that only runs if VERBOSE is on
|
108 | 105 | lib.log = function() {
|
109 | 106 | if(lib.VERBOSE) console.log.apply(console, arguments);
|
| 107 | + if(config.logging > 1) { |
| 108 | + console.log.apply(console, arguments); |
| 109 | + } |
110 | 110 | };
|
111 | 111 |
|
112 |
| -/** |
113 |
| - * markTime - for debugging, mark the number of milliseconds |
114 |
| - * since the previous call to markTime and log arbitrary info too |
115 |
| - */ |
116 |
| -lib.markTime = function(v) { |
117 |
| - if(!lib.VERBOSE) return; |
118 |
| - var t2 = new Date().getTime(); |
119 |
| - console.log(v, t2 - lib.TIMER, '(msec)'); |
120 |
| - if(lib.VERBOSE === 'trace') console.trace(); |
121 |
| - lib.TIMER = t2; |
| 112 | +lib.warn = function() { |
| 113 | + if(config.logging > 0) { |
| 114 | + console.warn.apply(console, arguments); |
| 115 | + } |
| 116 | +}; |
| 117 | + |
| 118 | +lib.error = function() { |
| 119 | + if(config.logging > 0) { |
| 120 | + console.error.apply(console, arguments); |
| 121 | + } |
122 | 122 | };
|
123 | 123 |
|
124 | 124 | // constrain - restrict a number v to be between v0 and v1
|
@@ -271,18 +271,17 @@ lib.syncOrAsync = function(sequence, arg, finalStep) {
|
271 | 271 | var ret, fni;
|
272 | 272 |
|
273 | 273 | function continueAsync() {
|
274 |
| - lib.markTime('async done ' + fni.name); |
275 | 274 | return lib.syncOrAsync(sequence, arg, finalStep);
|
276 | 275 | }
|
| 276 | + |
277 | 277 | while(sequence.length) {
|
278 | 278 | fni = sequence.splice(0, 1)[0];
|
279 | 279 | ret = fni(arg);
|
280 |
| - // lib.markTime('done calling '+fni.name) |
| 280 | + |
281 | 281 | if(ret && ret.then) {
|
282 | 282 | return ret.then(continueAsync)
|
283 | 283 | .then(undefined, lib.promiseError);
|
284 | 284 | }
|
285 |
| - lib.markTime('sync done ' + fni.name); |
286 | 285 | }
|
287 | 286 |
|
288 | 287 | return finalStep && finalStep(arg);
|
@@ -434,6 +433,7 @@ lib.addStyleRule = function(selector, styleString) {
|
434 | 433 | styleSheet.addRule(selector, styleString, 0);
|
435 | 434 | }
|
436 | 435 | else console.warn('addStyleRule failed');
|
| 436 | + else lib.warn('addStyleRule failed'); |
437 | 437 | };
|
438 | 438 |
|
439 | 439 | lib.getTranslate = function(element) {
|
|
0 commit comments