add some logging options for GUN messages

This commit is contained in:
Jesse D. McDonald 2020-03-28 22:29:38 -05:00
parent 72650faded
commit 2e324b180c
1 changed files with 28 additions and 3 deletions

View File

@ -10,15 +10,40 @@ $(function (){
peers: ['https://jessemcdonald.info/gun'], peers: ['https://jessemcdonald.info/gun'],
}); });
gun._.on('in', function(msg) {
if (window.logGunIn &&
(typeof window.logGunIn !== 'function' ||
window.logGunIn(msg)))
{
console.log('in msg: ', msg);
}
});
gun._.on('out', function(msg) {
if (window.logGunOut &&
(typeof window.logGunOut !== 'function' ||
window.logGunOut(msg)))
{
console.log('out msg: ', msg);
}
});
function debug() {
if (window.logDebug) {
console.log.apply(console, arguments);
}
}
window.logGunIn = false;
window.logGunOut = false;
window.logDebug = false;
const PS = window.PacoSako; const PS = window.PacoSako;
let currentGame = new PS.Game(); let currentGame = new PS.Game();
let visibleGame = new PS.Game(currentGame); let visibleGame = new PS.Game(currentGame);
let cancelGameCallback = function() {}; let cancelGameCallback = function() {};
let cancelMetaCallback = function() {}; let cancelMetaCallback = function() {};
//function debug() { console.log.apply(console, arguments); }
function debug() {}
function pieceTypeCode(type) { function pieceTypeCode(type) {
if (type === PS.KING) { if (type === PS.KING) {
return 'k'; return 'k';