2017-02-04 21:26:00 -05:00
|
|
|
/*
|
|
|
|
|
* noVNC: HTML5 VNC client
|
2024-11-27 13:58:26 +01:00
|
|
|
* Copyright (C) 2019 The noVNC authors
|
2017-02-04 21:26:00 -05:00
|
|
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
|
|
|
*
|
|
|
|
|
* See README.md for usage and integration instructions.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Logging/debug routines
|
|
|
|
|
*/
|
|
|
|
|
|
2020-05-31 23:24:58 +02:00
|
|
|
let _logLevel = 'warn';
|
2017-02-04 21:26:00 -05:00
|
|
|
|
2018-07-09 22:47:29 +02:00
|
|
|
let Debug = () => {};
|
|
|
|
|
let Info = () => {};
|
|
|
|
|
let Warn = () => {};
|
|
|
|
|
let Error = () => {};
|
2017-02-04 21:26:00 -05:00
|
|
|
|
2020-05-31 23:24:58 +02:00
|
|
|
export function initLogging(level) {
|
2017-02-04 21:26:00 -05:00
|
|
|
if (typeof level === 'undefined') {
|
2020-05-31 23:24:58 +02:00
|
|
|
level = _logLevel;
|
2017-02-04 21:26:00 -05:00
|
|
|
} else {
|
2020-05-31 23:24:58 +02:00
|
|
|
_logLevel = level;
|
2017-02-04 21:26:00 -05:00
|
|
|
}
|
|
|
|
|
|
2018-07-09 22:47:29 +02:00
|
|
|
Debug = Info = Warn = Error = () => {};
|
2018-05-24 00:25:44 +03:00
|
|
|
|
2017-02-04 21:26:00 -05:00
|
|
|
if (typeof window.console !== "undefined") {
|
2018-05-24 00:25:44 +03:00
|
|
|
/* eslint-disable no-console, no-fallthrough */
|
2017-02-04 21:26:00 -05:00
|
|
|
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-02-15 13:01:28 +01:00
|
|
|
throw new window.Error("invalid logging type '" + level + "'");
|
2017-02-04 21:26:00 -05:00
|
|
|
}
|
2018-05-24 00:25:44 +03:00
|
|
|
/* eslint-enable no-console, no-fallthrough */
|
2017-02-04 21:26:00 -05:00
|
|
|
}
|
2018-05-24 00:25:44 +03:00
|
|
|
}
|
|
|
|
|
|
2020-05-31 23:24:58 +02:00
|
|
|
export function getLogging() {
|
|
|
|
|
return _logLevel;
|
2018-05-24 00:25:44 +03:00
|
|
|
}
|
|
|
|
|
|
2017-02-04 21:26:00 -05:00
|
|
|
export { Debug, Info, Warn, Error };
|
|
|
|
|
|
|
|
|
|
// Initialize logging level
|
2020-05-31 23:24:58 +02:00
|
|
|
initLogging();
|