1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-29 09:35:22 +00:00
webvirtcloud/static/js/novnc/core/util/logging.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

/*
* noVNC: HTML5 VNC client
2020-08-11 12:05:09 +00:00
* Copyright (C) 2019 The noVNC Authors
* Licensed under MPL 2.0 (see LICENSE.txt)
*
* See README.md for usage and integration instructions.
*/
/*
* Logging/debug routines
*/
2020-08-11 12:05:09 +00:00
let _logLevel = 'warn';
2019-06-24 11:26:25 +00:00
let Debug = () => {};
let Info = () => {};
let Warn = () => {};
let Error = () => {};
2020-08-11 12:05:09 +00:00
export function initLogging(level) {
if (typeof level === 'undefined') {
2020-08-11 12:05:09 +00:00
level = _logLevel;
} else {
2020-08-11 12:05:09 +00:00
_logLevel = level;
}
2019-06-24 11:26:25 +00:00
Debug = Info = Warn = Error = () => {};
if (typeof window.console !== "undefined") {
2019-06-24 11:26:25 +00:00
/* eslint-disable no-console, no-fallthrough */
switch (level) {
case 'debug':
Debug = console.debug.bind(window.console);
case 'info':
Info = console.info.bind(window.console);
case 'warn':
Warn = console.warn.bind(window.console);
case 'error':
Error = console.error.bind(window.console);
case 'none':
break;
default:
2019-06-24 11:26:25 +00:00
throw new window.Error("invalid logging type '" + level + "'");
}
2019-06-24 11:26:25 +00:00
/* eslint-enable no-console, no-fallthrough */
}
2019-06-24 11:26:25 +00:00
}
2020-08-11 12:05:09 +00:00
export function getLogging() {
return _logLevel;
2019-06-24 11:26:25 +00:00
}
export { Debug, Info, Warn, Error };
// Initialize logging level
2020-08-11 12:05:09 +00:00
initLogging();