//////////////////////////////////////////////////////////////////////////////// // Constants //////////////////////////////////////////////////////////////////////////////// var __CFCONSOLE_ENABLED = false; //////////////////////////////////////////////////////////////////////////////// // Event Handlers //////////////////////////////////////////////////////////////////////////////// function __cfConsoleHandleError(message, url, lineNumber, stackTrace, loadStatus) { var s = "Error:\n\n"; if (typeof(message) != "undefined") { s += "\tMessage: " + message + '\n'; } if (typeof(url) != "undefined") { s += "\tURL: " + url + '\n'; } if (typeof(lineNumber) != "undefined") { s += "\tLine Number: " + lineNumber + '\n'; } if (typeof(loadStatus) != "undefined") { s += "\tLoad Status: " + loadStatus + '\n'; } if (typeof(stackTrace) != "undefined") { s += "\nStack Trace:\n\n" + stackTrace; } cfConsoleWrite(s); } function __cfConsoleHandleWarning(message) { cfConsoleWrite("Warning: " + message); } //////////////////////////////////////////////////////////////////////////////// // Private functions //////////////////////////////////////////////////////////////////////////////// function __cfConsoleGetDateString() { var d = new Date(); return d.toString() + " (" + d.getMilliseconds() + " ms)"; } //////////////////////////////////////////////////////////////////////////////// // Patches //////////////////////////////////////////////////////////////////////////////// function __cfConsoleWriteConsoleLog(s) { console.log(__cfConsoleGetDateString() + ": " + s + '\n'); } function __cfConsoleWriteDump(s) { dump(__cfConsoleGetDateString() + ": " + s + '\n'); } function __cfConsoleWriteUndefined(s) { // Nothing to do. } //////////////////////////////////////////////////////////////////////////////// // Initialization //////////////////////////////////////////////////////////////////////////////// if (__CFCONSOLE_ENABLED) { if (typeof(window.console) != "undefined") { if (typeof(window.console.log) != "undefined") { cfConsoleWrite = __cfConsoleWriteConsoleLog; } } else if (typeof(window.dump) != "undefined") { cfConsoleWrite = __cfConsoleWriteDump; } else { cfConsoleWrite = __cfConsoleWriteUndefined; } cfErrorAddOnErrorCallback(__cfConsoleHandleError); cfWarningAddOnWarningCallback(__cfConsoleHandleWarning); } else { cfConsoleWrite = __cfConsoleWriteUndefined; }