]> git.proxmox.com Git - mirror_novnc.git/blob - core/util/logging.js
Merge pull request #774 from novnc/refactor/es6-module-loader
[mirror_novnc.git] / core / util / logging.js
1 /*
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2012 Joel Martin
4 * Licensed under MPL 2.0 (see LICENSE.txt)
5 *
6 * See README.md for usage and integration instructions.
7 */
8
9 /*
10 * Logging/debug routines
11 */
12
13 var _log_level = 'warn';
14
15 var Debug = function (msg) {};
16 var Info = function (msg) {};
17 var Warn = function (msg) {};
18 var Error = function (msg) {};
19
20 export function init_logging (level) {
21 if (typeof level === 'undefined') {
22 level = _log_level;
23 } else {
24 _log_level = level;
25 }
26
27 Debug = Info = Warn = Error = function (msg) {};
28 if (typeof window.console !== "undefined") {
29 /* jshint -W086 */
30 switch (level) {
31 case 'debug':
32 Debug = console.debug.bind(window.console);
33 case 'info':
34 Info = console.info.bind(window.console);
35 case 'warn':
36 Warn = console.warn.bind(window.console);
37 case 'error':
38 Error = console.error.bind(window.console);
39 case 'none':
40 break;
41 default:
42 throw new Error("invalid logging type '" + level + "'");
43 }
44 /* jshint +W086 */
45 }
46 };
47 export function get_logging () {
48 return _log_level;
49 };
50 export { Debug, Info, Warn, Error };
51
52 // Initialize logging level
53 init_logging();