65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
|
/*
|
||
|
* from noVNC: HTML5 VNC client
|
||
|
* Copyright (C) 2012 Joel Martin
|
||
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||
|
*
|
||
|
* See README.md for usage and integration instructions.
|
||
|
*/
|
||
|
|
||
|
"use strict";
|
||
|
/*jslint bitwise: false, white: false */
|
||
|
/*global window, console, document, navigator, ActiveXObject */
|
||
|
|
||
|
// Globals defined here
|
||
|
var Log = {};
|
||
|
|
||
|
/*
|
||
|
* ------------------------------------------------------
|
||
|
* Namespaced in Util
|
||
|
* ------------------------------------------------------
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
* Logging/debug routines
|
||
|
*/
|
||
|
|
||
|
Log._log_level = 'none';
|
||
|
Log.init_logging = function (level) {
|
||
|
if (typeof level === 'undefined') {
|
||
|
level = Log._log_level;
|
||
|
} else {
|
||
|
Log._log_level = level;
|
||
|
}
|
||
|
if (typeof window.console === "undefined") {
|
||
|
if (typeof window.opera !== "undefined") {
|
||
|
window.console = {
|
||
|
'log' : window.opera.postError,
|
||
|
'warn' : window.opera.postError,
|
||
|
'error': window.opera.postError };
|
||
|
} else {
|
||
|
window.console = {
|
||
|
'log' : function(m) {},
|
||
|
'warn' : function(m) {},
|
||
|
'error': function(m) {}};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Log.Debug = Log.Info = Log.Warn = Log.Error = function (msg) {};
|
||
|
switch (level) {
|
||
|
case 'debug': Log.Debug = function (msg) { console.log(msg); };
|
||
|
case 'info': Log.Info = function (msg) { console.log(msg); };
|
||
|
case 'warn': Log.Warn = function (msg) { console.warn(msg); };
|
||
|
case 'error': Log.Error = function (msg) { console.error(msg); };
|
||
|
case 'none':
|
||
|
break;
|
||
|
default:
|
||
|
throw("invalid logging type '" + level + "'");
|
||
|
}
|
||
|
};
|
||
|
Log.get_logging = function () {
|
||
|
return Log._log_level;
|
||
|
};
|
||
|
|
||
|
// Initialize logging level
|
||
|
Log.init_logging();
|