Allow for the omission of particular frames in SOCKET_DEBUG

In particular, mediaUpdate spam.
This commit is contained in:
Xaekai 2022-01-22 07:55:36 -08:00 committed by Calvin Montgomery
parent de1f37735b
commit 500f295506

View file

@ -1173,18 +1173,25 @@ Callbacks = {
} }
} }
var SOCKET_DEBUG = localStorage.getItem('cytube_socket_debug') === 'true'; var SOCKET_DEBUG = {
enabled: (localStorage.getItem('cytube_socket_debug') === 'true'),
omit: (((data)=>{
const frames = data === null ? [] : JSON.parse(data);
return frames;
})(localStorage.getItem('cytube_socket_omissions')))
}
setupCallbacks = function() { setupCallbacks = function() {
for(var key in Callbacks) { for(var key in Callbacks) {
(function(key) { (function(key) {
socket.on(key, function(data) { socket.on(key, function(data) {
if (SOCKET_DEBUG) { if (SOCKET_DEBUG.enabled && !SOCKET_DEBUG.omit.includes(key)) {
console.log(key, data); console.log(key, data);
} }
try { try {
Callbacks[key](data); Callbacks[key](data);
} catch (e) { } catch (e) {
if (SOCKET_DEBUG) { if (SOCKET_DEBUG.enabled) {
console.log("EXCEPTION: " + e + "\n" + e.stack); console.log("EXCEPTION: " + e + "\n" + e.stack);
} }
} }