<script language="javascript">
var USE_DEBUG = true;
var LOG_LEVEL = 1;
var DEBUG = 1;
var INFO = 2;
var WARN = 3;
var getLogger = function() {
var myLogger = null;
var lvl = LOG_LEVEL;
if (!(typeof console === 'undefined')) {
if (LOG_LEVEL >= DEBUG || LOG_LEVEL >= INFO || LOG_LEVEL >= WARN) {
myLogger = console;
}
}
return {
isDebug: function() {
return myLogger && LOG_LEVEL >= lvl;
}
, isInfo: function() {
return myLogger && LOG_LEVEL >= lvl;
}
, debug: function(/** String */ mesg) {
myLogger.debug(mesg);
}
, get: function() {
return myLogger;
}
};
}();
// debugger;
if (getLogger.isDebug()) {
getLogger.debug('debug : abc');
} else {
alert('aaaa');
}
if (getLogger.isInfo()) {
getLogger.get().info('info : abc');
} else {
alert('aaaa');
}
</script>