diff --git a/src/hub.html b/src/hub.html index 45a849b2fc267bb1b35cdf84fe8be64be50852a7..1b840263256ffed825b44ecfb0e9bae8377d6598 100644 --- a/src/hub.html +++ b/src/hub.html @@ -10,9 +10,6 @@ <link rel="shortcut icon" type="image/png" href="/favicon.ico"> <title>Get together | Hubs by Mozilla</title> <link href="https://fonts.googleapis.com/css?family=Zilla+Slab:300,300i,400,400i,700" rel="stylesheet"> - - <!-- HACK: this has to run after A-Frame but before our bundle, since A-Frame blows away the local storage setting --> - <script src="https://cdn.rawgit.com/gfodor/ba8f88d9f34fe9cbe59a01ce3c48420d/raw/03e31f0ef7b9eac5e947bd39e440f34df0701f75/naf-janus-adapter-logging.js" integrity="sha384-4q1V8Q88oeCFriFefFo5uEUtMzbw6K116tFyC9cwbiPr6wEe7050l5HoJUxMvnzj" crossorigin="anonymous"></script> </head> <body> diff --git a/src/hub.js b/src/hub.js index 564462417517e2ac606c2c2a371957605230194f..cc6ad39c604f508bb1a3863577a3ba040c738aec 100644 --- a/src/hub.js +++ b/src/hub.js @@ -3,6 +3,7 @@ console.log(`Hubs version: ${process.env.BUILD_VERSION || "?"}`); import "./assets/stylesheets/hub.scss"; import "aframe"; +import "./utils/logging"; import { patchWebGLRenderingContext } from "./utils/webgl"; patchWebGLRenderingContext(); diff --git a/src/utils/logging.js b/src/utils/logging.js new file mode 100644 index 0000000000000000000000000000000000000000..1114f65729fdcbebb063276495031eea532bdcd5 --- /dev/null +++ b/src/utils/logging.js @@ -0,0 +1,18 @@ +// A-Frame blows away any npm debug log filters so this allow the user to set the log filter +// via the query string. +import debug from "debug"; + +const qs = new URLSearchParams(location.search); + +function qsTruthy(param) { + const val = qs.get(param); + // if the param exists but is not set (e.g. "?foo&bar"), its value is the empty string. + return val === "" || /1|on|true/i.test(val); +} + +const isDebug = qsTruthy("debug"); +const logFilter = qs.get("log_filter") || (isDebug && "naf-janus-adapter:*"); + +if (logFilter) { + debug.enable(logFilter); +}