mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Added better console logs
This commit is contained in:
parent
2dfdf703fd
commit
4108d696e4
@ -317,7 +317,7 @@ var common = (function() {
|
||||
function updateStatus(opt_message) {
|
||||
if (opt_message) {
|
||||
statusText = opt_message;
|
||||
console.log('common.js: ' + statusText);
|
||||
console.log('%c[updateStatus, common.js]', 'color: gray;', statusText);
|
||||
}
|
||||
var statusField = document.getElementById('statusField');
|
||||
if (statusField) {
|
||||
|
@ -157,7 +157,7 @@ function beginBackgroundPollingOfHost(host) {
|
||||
}
|
||||
|
||||
function stopBackgroundPollingOfHost(host) {
|
||||
console.log('stopping background polling of server: ' + host.toString());
|
||||
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];
|
||||
}
|
||||
@ -187,26 +187,24 @@ function updateBitrateField() {
|
||||
|
||||
function moduleDidLoad() {
|
||||
if(!myUniqueid) {
|
||||
console.log("Failed to get uniqueId. We should have already generated one. Regenerating...");
|
||||
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.');
|
||||
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,7 +524,7 @@ 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!');
|
||||
console.error('%c[Moonlight GUI, startGame]', 'color: green;', 'Attempted to start a game, but `host` did not initialize properly. Host object: ', host);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ function handleMessage(msg) {
|
||||
callbacks[msg.data.callbackId][msg.data.type](msg.data.ret);
|
||||
delete callbacks[msg.data.callbackId]
|
||||
} else { // else, it's just info, or an event
|
||||
console.log(msg.data);
|
||||
console.log('%c[handleMessage]', 'color:gray;', 'Message data: ', msg.data)
|
||||
if(msg.data === 'streamTerminated') { // if it's a recognized event, notify the appropriate function
|
||||
$('#loadingSpinner').css('display', 'none'); // This is a fallback for RTSP handshake failing, which immediately terminates the stream.
|
||||
$('body').css('backgroundColor', '#282C38');
|
||||
|
@ -32,7 +32,7 @@ String.prototype.toHex = function() {
|
||||
}
|
||||
|
||||
function NvHTTP(address, clientUid, userEnteredAddress = '') {
|
||||
console.log(this);
|
||||
console.log('%c[NvHTTP Object]', 'color: gray;', this);
|
||||
this.address = address;
|
||||
this.paired = false;
|
||||
this.currentGame = 0;
|
||||
@ -95,7 +95,7 @@ NvHTTP.prototype = {
|
||||
// try HTTPS first
|
||||
return sendMessage('openUrl', [ 'https://' + givenAddress + ':47984' + '/serverinfo?' + this._buildUidStr(), false]).then(function(ret) {
|
||||
if (!this._parseServerInfo(ret)) { // if that fails
|
||||
console.log('Failed to parse serverinfo from HTTPS, falling back to HTTP');
|
||||
console.log('%c[utils.js, refreshServerInfoAtAddress]', 'color: gray;', 'Failed to parse serverinfo from HTTPS, falling back to HTTP');
|
||||
// try HTTP as a failover. Useful to clients who aren't paired yet
|
||||
return sendMessage('openUrl', [ 'http://' + givenAddress + ':47989' + '/serverinfo?' + this._buildUidStr(), false]).then(function(retHttp) {
|
||||
return this._parseServerInfo(retHttp);
|
||||
@ -165,7 +165,7 @@ NvHTTP.prototype = {
|
||||
this.refreshServerInfoAtAddress(this.userEnteredAddress).then(function(successUserEntered) {
|
||||
onSuccess(this.userEnteredAddress);
|
||||
}.bind(this), function(failureUserEntered) {
|
||||
console.log('WARN! Failed to contact host: ' + this.hostname + '\r\n' + this.toString());
|
||||
console.warn('%c[utils.js, selectServerAddress]', 'color: gray;', 'Failed to contact host ' + this.hostname, this);
|
||||
onFailure();
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
@ -208,8 +208,7 @@ NvHTTP.prototype = {
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log('parsing server info: ');
|
||||
console.log($root);
|
||||
console.log('%c[_parseServerInfo]', 'color:gray;', 'Parsing server info:', $root);
|
||||
|
||||
this.paired = $root.find("PairStatus").text().trim() == 1;
|
||||
this.currentGame = parseInt($root.find("currentgame").text().trim(), 10);
|
||||
@ -290,7 +289,7 @@ NvHTTP.prototype = {
|
||||
|
||||
if ($root.attr("status_code") != 200) {
|
||||
// TODO: Bubble up an error here
|
||||
console.log('applist request failed: ' + $root.attr("status_code"));
|
||||
console.error('%c[utils.js, getAppListWithCacheFlush]', 'color: gray;', 'Applist request failed', $root.attr("status_code"));
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -314,7 +313,7 @@ NvHTTP.prototype = {
|
||||
getAppList: function () {
|
||||
if (this._memCachedApplist) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
console.log('returning memory cached app list');
|
||||
console.log('%c[Moonlight GUI]', 'color: green;', 'Returning memory-cached apps list');
|
||||
resolve(this._memCachedApplist);
|
||||
return;
|
||||
}.bind(this));
|
||||
@ -327,11 +326,11 @@ NvHTTP.prototype = {
|
||||
// this is inefficient, but works well.
|
||||
warmBoxArtCache: function () {
|
||||
if (!this.paired) {
|
||||
console.log('not warming box art cache from unpaired host.');
|
||||
console.log('%c[warmBoxArtCache, utils.js]', 'color: grey;', 'Not warming box art cache for unpaired host');
|
||||
return;
|
||||
}
|
||||
if (Object.keys(this._memCachedBoxArtArray).length != 0) {
|
||||
console.log('box art cache already warmed.');
|
||||
console.log('%c[warmBoxArtCache, utils.js]', 'color: grey;', 'Box art cache already warmed');
|
||||
return;
|
||||
}
|
||||
if (chrome.storage) {
|
||||
@ -343,9 +342,9 @@ NvHTTP.prototype = {
|
||||
for (var key in storedBoxArtArray) {
|
||||
this._memCachedBoxArtArray[key] = _base64ToArrayBuffer(storedBoxArtArray[key]);
|
||||
}
|
||||
console.log('box art cache warmed.');
|
||||
console.log('%c[warmBoxArtCache, utils.js]', 'color: grey;', 'Box art cache warmed');
|
||||
} else {
|
||||
console.log('WARN: no box art found in storage. Cannot warm cache!');
|
||||
console.warn('%c[warmBoxArtCache, utils.js]', 'color: grey;', 'No box art found in storage. Cannot warm cache!');
|
||||
return;
|
||||
}
|
||||
}.bind(this));
|
||||
@ -361,13 +360,13 @@ NvHTTP.prototype = {
|
||||
if (this._memCachedBoxArtArray[appId] === null) {
|
||||
// This means a previous box art request failed, don't try again
|
||||
return new Promise(function (resolve, reject) {
|
||||
console.log('returning cached box art failure result');
|
||||
console.error('%c[utils.js, getBoxArt]', 'color: gray;', 'Returning cached box-art failure result')
|
||||
reject(null);
|
||||
return;
|
||||
}.bind(this));
|
||||
} else if (this._memCachedBoxArtArray[appId] !== undefined) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
console.log('returning memory cached box art');
|
||||
console.log('%c[utils.js, getBoxArt]', 'color: gray;', 'Returning memory-cached box-art');
|
||||
resolve(this._memCachedBoxArtArray[appId]);
|
||||
return;
|
||||
}.bind(this));
|
||||
@ -392,7 +391,7 @@ NvHTTP.prototype = {
|
||||
|
||||
// if we already have it, load it.
|
||||
if (storedBoxArtArray[appId] !== undefined && Object.keys(storedBoxArtArray).length !== 0 && storedBoxArtArray[appId].constructor !== Object) {
|
||||
console.log('returning storage cached box art');
|
||||
console.log('%c[getBoxArt, utils.js]', 'color: gray;', 'Returning strage-cached box art for app: ', appId);
|
||||
resolve(storedBoxArtArray[appId]);
|
||||
return;
|
||||
}
|
||||
@ -416,13 +415,13 @@ NvHTTP.prototype = {
|
||||
|
||||
obj['boxArtCache'] = arrayToStore; // storage is in JSON format. JSON does not support binary data.
|
||||
chrome.storage.local.set(obj, function(onSuccess) {});
|
||||
console.log('returning streamed box art');
|
||||
console.log('%c[utils.js, getBoxArt]', 'color: gray;', 'Returning streamed box art');
|
||||
resolve(streamedBoxArt);
|
||||
return;
|
||||
}.bind(this), function(error) {
|
||||
// Cache the failure but not persistently
|
||||
this._memCachedBoxArtArray[appId] = null;
|
||||
console.log('box art request failed');
|
||||
console.error('%c[utils.js, getBoxArt]', 'color: gray;', 'Box-art request failed!', error);
|
||||
reject(error);
|
||||
return;
|
||||
}.bind(this));
|
||||
@ -430,7 +429,7 @@ NvHTTP.prototype = {
|
||||
}.bind(this));
|
||||
|
||||
} else { // shouldn't run because we always have chrome.storage, but I'm not going to antagonize other browsers
|
||||
console.log('WARN: Chrome.storage not detected! Box art will not be saved!');
|
||||
console.warn('%c[utils.js, getBoxArt]', 'color: gray;', 'chrome.storage not detected! Box art will not be saved!');
|
||||
return sendMessage('openUrl', [
|
||||
this._baseUrlHttps +
|
||||
'/appasset?'+this._buildUidStr() +
|
||||
|
Loading…
x
Reference in New Issue
Block a user