debug logging is conditional in figwheel-bridge.js fixes #30

This commit is contained in:
Artur Girenko 2016-03-21 23:05:45 +01:00
parent d7567b4de4
commit 5d4d6d6651
1 changed files with 13 additions and 6 deletions

View File

@ -5,6 +5,7 @@
*/ */
var CLOSURE_UNCOMPILED_DEFINES = null; var CLOSURE_UNCOMPILED_DEFINES = null;
var debugEnabled = false;
var config = { var config = {
basePath: "target/", basePath: "target/",
@ -59,13 +60,19 @@ var figwheelApp = function (platform, devHost) {
}) })
}; };
function logDebug(msg) {
if (debugEnabled) {
console.log(msg);
}
}
// evaluates js code ensuring proper ordering // evaluates js code ensuring proper ordering
function customEval(url, javascript, success, error) { function customEval(url, javascript, success, error) {
if (scriptQueue.length > 0) { if (scriptQueue.length > 0) {
if (scriptQueue[0] === url) { if (scriptQueue[0] === url) {
try { try {
evaluate(javascript); evaluate(javascript);
console.info('Evaluated: ' + url); logDebug('Evaluated: ' + url);
scriptQueue.shift(); scriptQueue.shift();
evalListeners.forEach(function (listener) { evalListeners.forEach(function (listener) {
listener(url) listener(url)
@ -92,7 +99,7 @@ var isChrome = function () {
}; };
function asyncImportScripts(url, success, error) { function asyncImportScripts(url, success, error) {
console.info('(asyncImportScripts) Importing: ' + url); logDebug('(asyncImportScripts) Importing: ' + url);
scriptQueue.push(url); scriptQueue.push(url);
fetch(url) fetch(url)
.then(function (response) { .then(function (response) {
@ -111,7 +118,7 @@ function asyncImportScripts(url, success, error) {
function syncImportScripts(url, success, error) { function syncImportScripts(url, success, error) {
try { try {
importScripts(url); importScripts(url);
console.info('Evaluated: ' + url); logDebug('Evaluated: ' + url);
evalListeners.forEach(function (listener) { evalListeners.forEach(function (listener) {
listener(url) listener(url)
}); });
@ -134,7 +141,7 @@ function importJs(src, success, error) {
var file = fileBasePath + '/' + src; var file = fileBasePath + '/' + src;
console.info('(importJs) Importing: ' + file); logDebug('(importJs) Importing: ' + file);
if (isChrome()) { if (isChrome()) {
syncImportScripts(serverBaseUrl("localhost") + '/' + file, success, error); syncImportScripts(serverBaseUrl("localhost") + '/' + file, success, error);
} else { } else {
@ -185,12 +192,12 @@ function loadApp(platform, devHost, onLoadCb) {
evalListeners.push(function (url) { evalListeners.push(function (url) {
if (url.indexOf(mainJs) > -1) { if (url.indexOf(mainJs) > -1) {
onLoadCb(env[platform].main.root_el); onLoadCb(env[platform].main.root_el);
console.log('Done loading Clojure app'); console.info('Done loading Clojure app');
} }
}); });
if (typeof goog === "undefined") { if (typeof goog === "undefined") {
console.log('Loading Closure base.'); console.info('Loading Closure base.');
interceptRequire(); interceptRequire();
compileWarningsToYellowBox(); compileWarningsToYellowBox();
importJs('goog/base.js', function () { importJs('goog/base.js', function () {