]> git.proxmox.com Git - mirror_novnc.git/blob - core/util/logging.js
Merge pull request #989 from PeterDaveHelloKitchen/update-travis-ci
[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 switch (level) {
30 case 'debug':
31 Debug = console.debug.bind(window.console);
32 case 'info':
33 Info = console.info.bind(window.console);
34 case 'warn':
35 Warn = console.warn.bind(window.console);
36 case 'error':
37 Error = console.error.bind(window.console);
38 case 'none':
39 break;
40 default:
41 throw new Error("invalid logging type '" + level + "'");
42 }
43 }
44 };
45 export function get_logging () {
46 return _log_level;
47 };
48 export { Debug, Info, Warn, Error };
49
50 // Initialize logging level
51 init_logging();