📄 log.js
字号:
/*
* Isomorphic SmartClient
* Version 6.5 (2008-04-30)
* Copyright(c) 1998-2007 Isomorphic Software, Inc. All rights reserved.
* "SmartClient" is a trademark of Isomorphic Software, Inc.
*
* licensing@smartclient.com
*
* http://smartclient.com/license
*/
// The log functions below will always be defined even with DEBUG> <DEBUG blocks stripped, so that // if an end user calls a log function and forgets to mark it with DEBUG, it doesn't result in a// JS error.// write special log accessor functions for Class instances so we can call themisc._logMethods = { logMessage : function (priority, message, category, timestamp) { var log = isc.Log; if (!log) return; //>DEBUG // if no priority was passed in, use the default if (priority == null) priority = log.defaultPriority; // automatically add a stack trace for error logs if (priority <= log.stackTracePriority && this.getStackTrace != null) { // skip two levels of the stack to avoid showing the logMessage() invocation itself message += "\nStack trace:\n" + this.getStackTrace(arguments, 2); } // If a category was not specified, use the name of this class. if (!category) category = this.Class; // actually do the log. NOTE: if we have an instance ID, pass it log.log(priority, message, category, this.ID, this, timestamp); //<DEBUG }, //> @method Log.logDebug() // Log a message at "debug" priority // <P> // A method named log<i>Priority</i> exists for each priority level, on every ISC Class and // instance of an ISC Class. Messages logged on a Class or instance have a default // category of the classname. Messages logged on an instance will also automatically // incorporate the instance ID. General best practice is to call logDebug() et al as // "this.logDebug" whenever "this" is an instance, or as "Log.logDebug" otherwise. // // @param message (String) message to log // @param [category] (String) category to log in // // @see Log.echo() for dumping datastructures to the log // @see Log.setPriority() for controlling what messages appear in the log // @visibility external //< logDebug : function (message, category) { return this.logMessage(isc.Log.DEBUG, message, category)}, //> @method Log.logInfo() // Log a message at "info" priority // // @param message (String) message to log // @param [category] (String) category to log in // // @see Log.logDebug() for usage info // @visibility external //< logInfo : function (message, category) { return this.logMessage(isc.Log.INFO, message, category)}, //> @method Log.logWarn() // Log a message at "warn" priority // // @param message (String) message to log // @param [category] (String) category to log in // // @see Log.logDebug() for usage info // @visibility external //< logWarn : function (message, category) { return this.logMessage(isc.Log.WARN, message, category)}, //> @method Log.logError() // Log a message at "error" priority // // @param message (String) message to log // @param [category] (String) category to log in // // @see Log.logDebug() for usage info // @visibility external //< logError : function (message, category) { return this.logMessage(isc.Log.ERROR, message, category)}, //> @method Log.logFatal() // Log a message at "fatal" priority // // @param message (String) message to log // @param [category] (String) category to log in // // @see Log.logDebug() for usage info // @visibility external //< logFatal : function (message, category) { return this.logMessage(isc.Log.FATAL, message, category)}, //> @method Log.logIsEnabledFor() // Check whether a message logged at the given priority would be visible in the log. // <P> // As with logDebug, category is defaulted to the current className. Use this method to avoid // putting together expensive log messages if they will never appear in the log. // // @param priority (LogPriority) priority level // @param [category] (String) category to log in // @visibility external //< logIsEnabledFor : function (priority, category) { return (isc.Log.isEnabledFor && isc.Log.isEnabledFor((category ? category : this.Class), priority, this)) }, //> @method Log.logIsDebugEnabled() // Check whether a message logged at "debug" priority would be visible in the log. // <P> // As with logDebug, category is defaulted to the current className. Use this method to avoid // putting together expensive log messages if they will never appear in the log. // // @param [category] (String) category to log in // @visibility external //< logIsDebugEnabled : function (category) { return this.logIsEnabledFor(isc.Log.DEBUG, category) }, //> @method Log.logIsInfoEnabled() // Check whether a message logged at "info" priority would be visible in the log. // <P> // As with logDebug, category is defaulted to the current className. Use this method to avoid // putting together expensive log messages if they will never appear in the log. // // @param [category] (String) category to log in // @visibility external //< logIsInfoEnabled : function (category) { return this.logIsEnabledFor(isc.Log.INFO, category) }, //> @method Log.logIsWarnEnabled() // Check whether a message logged at "warn" priority would be visible in the log. // <P> // As with logDebug, category is defaulted to the current className. Use this method to avoid // putting together expensive log messages if they will never appear in the log. // // @param [category] (String) category to log in // @visibility external //< logIsWarnEnabled : function (category) { return this.logIsEnabledFor(isc.Log.WARN, category) }, //> @method Log.logIsErrorEnabled() // Check whether a message logged at "error" priority would be visible in the log. // <P> // As with logDebug, category is defaulted to the current className. Use this method to avoid // putting together expensive log messages if they will never appear in the log. // // @param [category] (String) category to log in // @visibility external //< logIsErrorEnabled : function (category) { return this.logIsEnabledFor(isc.Log.ERROR, category) }, // Methods to update the log priority directly on objects //> @method Log.setLogPriority() // Set the priority of messages that will be visible for some log category, when logged on // this Class or Instance object.<br> // If called with no category, this priority will be applied to every logged message on this // object<br> // To set the visible log priority for some category across the entire page, use // <code>isc.Log.setPriority()</code> instead. // @param category (string) Category for which the log priority will be updated. If not // all logs on this canvas will be logged at the priority passed in. // @param priority (LogPriority) priority level // @see Log.setPriority() // @visibility external //< setLogPriority : function (category, priority) { isc.Log.setPriority(category, priority, this); }, //> @method Log.setDefaultLogPriority() // Set the default priority of logging for messages logged on this Class or Instance object. // All categories for which there is no explicit, instance level logging priority set will // log at this level on this object.<br> // To set the default visible log priority across the entire page, use // <code>isc.Log.setDefaultPriority()</code> instead. // @param category (string) Category for which the log priority will be updated. If not // all logs on this canvas will be logged at the priority passed in. // @param priority (LogPriority) priority level // @see Log.setPriority() // @visibility external //< setDefaultLogPriority : function (priority) { isc.Log.setDefaultPriority(priority, this); }, //> @classMethod Log.getDefaultLogPriority() // Retrieves the default priority of messages for this class or instance. // @return (LogPriority) default priority for logging messages on this object. // @visibility external //< getDefaultLogPriority : function () { return isc.Log.getDefaultPriority(this); }, //> @method Log.clearLogPriority() // Clear this object's priority setting for a particular category, so that the category's // effective priority returns to the specified priority for this category at the Log level // (or <code>Log.defaultPriority</code> if not set).<br> // To clear the Page-level priority setting for this log category use // <code>isc.Log.clearPriority()</code> instead. // // @param category (String) Category name. If not specified, all logging on this object // will revert to default priority settings. // @visibility external // @see Log.clearPriority() //< clearLogPriority : function (category) { isc.Log.clearPriority(category, this); } };// add the methods to Class object prototype and to the Class instance prototypeisc.Class.addMethods(isc._logMethods);isc.Class.addClassMethods(isc._logMethods);//> @groupDef debug// Support for debugging and logging//<//> @class Log// A logging system similar to the Java log4j package: messages are logged with a "category" and// "priority", and developers can dynamically set which log messages are being displayed.// <P>// 5 log priorities are available, with the following general meaning:// <ul>// <li> "debug": diagnostic info which is only likely to be understood by a developer with// source access, or would occur too frequently for normal usage// <li> "info": reports of significant events in the normal operation of the subsystem// <li> "warn": some kind of problem is likely to occur, an API appears is apparently being// misused or will yield a partial or very slow result// <li> "error": a definite error has occurred which may be recoverable// <li> "fatal": total failure with no possibility of recovery// </ul>// <P>// Log categories do not need to be declared in advance - you can simply make up a category name and// start logging to it, and control whether that category's messages will be displayed via// <code>setPriority()</code>.// <P>// <b>NOTE:</b> to open the Developer Console in any page that loads ISC, type// javascript:isc.Log.show() in the URL bar - this URL is bookmarkable. // <P>// The Developer Console should <b>always</b> be open while developing any ISC-enabled application,// because ISC logs many important errors and warnings to the Developer Console.// <P>// In Internet Explorer, the Developer Console is able to log a stack trace for every JS error,// including errors that occur in non-ISC code.// <P>// NOTE: if you have the Microsoft JavaScript Debugger installed, ISC will be unable to log stack// traces on JS errors until you go to Tools->Internet Options->Advanced Tab and check "Disable// script debugging". The ability to see stack traces in the Developer Console is generally much// more useful for debugging ISC-based applications than the generic Javascript Debugging// facilities.//// @treeLocation Client Reference/System// @group debug//// @see Log.setPriority()//// @visibility external//<isc.ClassFactory.defineClass("Log");//> @groupDef debugging// <h4>Built-in Diagnostics</h4>// <P>// In any page in which ISC has been loaded, you have access to the Developer Console,// which can be opened by entering the following URL into your browser from the running// application:// <pre>// javascript:isc.showConsole()</pre>// Basic information on the features of the Developer Console can be found in the QuickStart// Guide. This topic focuses on use of the log system and related debugging facilities.// <P>// The Developer Console contains a "Results" pane that displays a list of diagnostic// messages logged by the SmartClient framework. The "Logging Preferences" menu lets you// enable and disable SmartClient's built-in diagnostics in several categories. Because// important diagnostic messages may be logged at any time, you should have the Developer// Console open whenever you are working with SmartClient (and you should bookmark the// "javascript:" expression above to make this easier).// <P>// Log messages are of the format:// <P>// <i>timestamp</i>:<i>priority</i>:<i>category</i>:<i>message</i>// <P>// For example, the following log message:// <pre>// 11:59:25:806:INFO:Page:Page loading complete.</pre>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -