Added better console logs

This commit is contained in:
Paulin Jorys
2017-07-11 13:20:01 +02:00
parent 2dfdf703fd
commit 4108d696e4
4 changed files with 77 additions and 83 deletions

View File

@@ -157,9 +157,9 @@ function beginBackgroundPollingOfHost(host) {
}
function stopBackgroundPollingOfHost(host) {
console.log('stopping background polling of server: ' + host.toString());
window.clearInterval(activePolls[host.serverUid]);
delete activePolls[host.serverUid];
console.log('%c[Moonlight GUI, backgroundPolling]', 'color: green;', 'Stopping background polling of host ' + host.serverUid + '\n', host);
window.clearInterval(activePolls[host.serverUid]);
delete activePolls[host.serverUid];
}
function snackbarLog(givenMessage) {
@@ -187,26 +187,24 @@ function updateBitrateField() {
function moduleDidLoad() {
if(!myUniqueid) {
console.log("Failed to get uniqueId. We should have already generated one. Regenerating...");
myUniqueid = uniqueid();
storeData('uniqueid', myUniqueid, null);
console.warn('%c[Moonlight GUI, moduleDidLoad]', 'color: green;', 'Failed to get uniqueId. We should have already generated one. Regenerating...');
myUniqueid = uniqueid();
storeData('uniqueid', myUniqueid, null);
}
if(!pairingCert) { // we couldn't load a cert. Make one.
console.log("Failed to load local cert. Generating new one");
console.warn('%c[Moonlight GUI, moduleDidLoad]', 'color: green;', 'Failed to load local cert. Generating new one');
sendMessage('makeCert', []).then(function (cert) {
storeData('cert', cert, null);
pairingCert = cert;
console.log("Generated new cert.");
console.info('%c[Moonlight GUI, moduleDidLoad]', 'color: green;', 'Generated new cert:', cert);
}, function (failedCert) {
console.log('ERROR: failed to generate new cert!');
console.log('Returned error was: ' + failedCert);
console.error('%c[Moonlight GUI, moduleDidLoad]', 'color: green;', 'Failed to generate new cert! Returned error was: \n', failedCert);
}).then(function (ret) {
sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myUniqueid]).then(function (ret) {
restoreUiAfterNaClLoad();
}, function (failedInit) {
console.log('ERROR: failed httpInit!');
console.log('Returned error was: ' + failedInit);
console.error('%c[Moonlight GUI, moduleDidLoad]', 'color: green;', 'Failed httpInit! Returned error was: ', failedInit);
});
});
}
@@ -214,8 +212,7 @@ function moduleDidLoad() {
sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myUniqueid]).then(function (ret) {
restoreUiAfterNaClLoad();
}, function (failedInit) {
console.log('ERROR: failed httpInit!');
console.log('Returned error was: ' + failedInit);
console.error('%c[Moonlight GUI, moduleDidLoad]', 'color: green;', 'Failed httpInit! Returned error was: ', failedInit);
});
}
}
@@ -224,7 +221,7 @@ function moduleDidLoad() {
function pairTo(nvhttpHost, onSuccess, onFailure) {
if(!pairingCert) {
snackbarLog('ERROR: cert has not been generated yet. Is NaCl initialized?');
console.log("User wants to pair, and we still have no cert. Problem = very yes.");
console.warn('%c[Moonlight GUI]', 'color: green;', 'User wants to pair, and we still have no cert. Problem = very yes.');
onFailure();
return;
}
@@ -232,7 +229,7 @@ function pairTo(nvhttpHost, onSuccess, onFailure) {
nvhttpHost.pollServer(function (ret) {
if (!nvhttpHost.online) {
snackbarLog('Failed to connect to ' + nvhttpHost.hostname + '! Are you sure the host is on?');
console.log(nvhttpHost.toString());
console.error('%c[Moonlight GUI]', 'color: green;', 'Host declared as offline:', nvhttpHost, nvhttpHost.toString()); //Logging both the object and the toString version for text logs
onFailure();
return;
}
@@ -252,7 +249,7 @@ function pairTo(nvhttpHost, onSuccess, onFailure) {
pairingDialog.close();
});
console.log('sending pairing request to ' + nvhttpHost.hostname + ' with random number ' + randomNumber);
console.log('%c[Moonlight GUI]', 'color: green;', 'Sending pairing request to ' + nvhttpHost.hostname + ' with random number' + randomNumber);
nvhttpHost.pair(randomNumber).then(function (paired) {
if (!paired) {
if (nvhttpHost.currentGame != 0) {
@@ -260,8 +257,7 @@ function pairTo(nvhttpHost, onSuccess, onFailure) {
} else {
$('#pairingDialogText').html('Error: failed to pair with ' + nvhttpHost.hostname + '.');
}
console.log('failed API object: ');
console.log(nvhttpHost.toString());
console.log('%c[Moonlight GUI]', 'color: green;', 'Failed API object:', nvhttpHost, nvhttpHost.toString()); //Logging both the object and the toString version for text logs
onFailure();
return;
}
@@ -271,9 +267,8 @@ function pairTo(nvhttpHost, onSuccess, onFailure) {
onSuccess();
}, function (failedPairing) {
snackbarLog('Failed pairing to: ' + nvhttpHost.hostname);
console.log('pairing failed, and returned ' + failedPairing);
console.log('failed API object: ');
console.log(nvhttpHost.toString());
console.error('%c[Moonlight GUI]', 'color: green;', 'Pairing failed, and returned:', failedPairing);
console.error('%c[Moonlight GUI]', 'color: green;', 'Failed API object:', nvhttpHost, nvhttpHost.toString()); //Logging both the object and the toString version for text logs
onFailure();
});
});
@@ -409,10 +404,10 @@ function stylizeBoxArt(freshApi, appIdToStylize) {
// show the app list
function showApps(host) {
if(!host || !host.paired) { // safety checking. shouldn't happen.
console.log('Moved into showApps, but `host` did not initialize properly! Failing.');
return;
console.log('%c[Moonlight GUI, showApps]', 'color: green;', 'Moved into showApps, but `host` did not initialize properly! Failing.');
return;
}
console.log(host);
console.log('%c[Moonlight GUI, showApps]', 'color: green;', 'Current host object:', host);
$('#quitCurrentApp').show();
$("#gameList .game-container").remove();
@@ -491,7 +486,7 @@ function showApps(host) {
// set the layout to the initial mode you see when you open moonlight
function showHostsAndSettingsMode() {
console.log('entering show hosts and settings mode.');
console.log('%c[Moonlight GUI]', 'color: green;', 'Entering "Show apps and hosts" mode');
$("#main-navigation").show();
$(".nav-menu-parent").show();
$("#externalAudioBtn").show();
@@ -506,7 +501,7 @@ function showHostsAndSettingsMode() {
}
function showAppsMode() {
console.log("entering show apps mode.");
console.log('%c[Moonlight GUI]', 'color: green;', 'Entrering "Show apps" mode');
$('#backIcon').show();
$("#main-navigation").show();
$("#main-content").children().not("#listener, #loadingSpinner, #naclSpinner").show();
@@ -529,8 +524,8 @@ function showAppsMode() {
// if the given app is already running, just resume it.
function startGame(host, appID) {
if(!host || !host.paired) {
console.log('attempted to start a game, but `host` did not initialize properly. Failing!');
return;
console.error('%c[Moonlight GUI, startGame]', 'color: green;', 'Attempted to start a game, but `host` did not initialize properly. Host object: ', host);
return;
}
// refresh the server info, because the user might have quit the game.
@@ -789,7 +784,7 @@ function updateDefaultBitrate() {
}
function onWindowLoad(){
console.log('Window loaded.');
console.log('%c[Moonlight GUI]', 'color: green;', 'Moonlight\'s main window loaded');
// don't show the game selection div
$('#gameSelection').css('display', 'none');
@@ -861,7 +856,7 @@ function onWindowLoad(){
revivedHost.hostname = hosts[hostUID].hostname;
addHostToGrid(revivedHost);
}
console.log('Loaded previously connected hosts.');
console.log('%c[Moonlight GUI]', 'color: green;', 'Loaded previously connected hosts');
});
}
}