IE doesn't have console.debug, and it also is a pain to log with an object.

This commit is contained in:
Andy Janata 2012-01-30 00:36:21 -08:00
parent 84373a5453
commit 0f14cb781c
1 changed files with 17 additions and 1 deletions

View File

@ -35,7 +35,23 @@ cah.log.error = function(text) {
*/
cah.log.debug = function(text, opt_obj) {
if (cah.SILENT_DEBUG && console) {
console.debug("[" + new Date().toLocaleTimeString() + "]", text, opt_obj);
if (console.debug) {
console.debug("[" + new Date().toLocaleTimeString() + "]", text, opt_obj);
} else if (console.log) {
console.log("[" + new Date().toLocaleTimeString() + "] " + text);
if (opt_obj) {
if (console.dir) {
console.dir(opt_obj);
} else if (JSON && JSON.stringify) {
console.log(JSON.stringify(opt_obj));
} else {
console.log("TODO: SILENT_DEBUG without console.debug, with console.log, "
+ "without console.dir, without JSON.stringify");
}
}
} else if (console.log) {
console.log("[" + new Date().toLocaleTimeString() + "]", text, opt_obj);
}
}
if (cah.DEBUG) {
if (opt_obj) {