Sie sind auf Seite 1von 1

YUI Library: Logger 2008-2-19 v2.

5
Simple Use Case (LogReader) Simple Use Case (Logger) YAHOO.widget.Logger
Static Properties:
<div id="myLogger"></div> YAHOO.log("My log message", "error", "mysource");
loggerEnabled (b)
<script>
Logs a message to the default console and to console.log(), if maxStackEntries (int)
var myLogReader = new
enabled; the source is "mysource" and the category is "error". Custom
YAHOO.widget.LogReader YAHOO.widget.Logger
categories and sources can be added on the fly.
("myLogger"); Static Methods:
</script>
Instantiates a new LogReader
Constructor (LogWriter) log(sMsg, sCategory,
sSource)
object, myLogReader, which is Creates a separate, named bucket for your log messages: disableBrowserConsole()
bound to a div whose id attribute enableBrowserConsole()
YAHOO.widget.LogWriter(str sSource); getStack()
is 'myLogger'. The result will be a
getStartTime()
visual LogReader display. Arguments:
reset()
To create a LogReader that floats (1) Source (string): The source of log messages. The first word of the
outside the page context, omit the reference to a context div. Your string will be used to create a LogReader filter checkbox. The entire YAHOO.widget.Logger
LogReader will then be appended to the page and positioned string will be prepended to log messages so they can be easily Custom Events:
absolutely. If the YUI Drag & Drop Library is included on the page, it tracked by their source.
categoryCreateEvent
will be draggable. sourceCreateEvent
Solutions newLogEvent
logResetEvent
Constructor (LogReader) Log a message using a pre-styled logging category:
LogReader Properties:
YAHOO.widget.LogReader([str html id | obj element YAHOO.log("My log message.", "warn");
reference, obj configuration object]); verboseOutput (b)
Create a new logging category on the fly: newestOnTop (b)
Arguments: YAHOO.log("My log message.", "myCategory"); thresholdMax (int)
(1) HTML element (string or object): An optional reference to an thresholdMin (int)
HTML id string or element object binds the LogReader to an existing Style a custom logging category in CSS: outputBuffer (int)
page element. .yui-log .myCategory {background-color:#dedede;} LogReader Methods:
(2) Configuration object (object): An optional object literal defines
LogReader settings. All properties of a LogReader instance can be Log a message, creating a new "source" on the fly: hide()/show()
pause()/resume()
set via the constructor by using this object. YAHOO.log("My log message.", "warn", "newSource"); collapse()/expand()
In script, hide and show the logging console: clearConsole()
Logging via console.log() hideCategory()/
myLogReader.hide(); showCategory()
A growing number of browsers and myLogReader.show(); hideSource()/
extensions support the JavaScript In script, pause and resume output to the console: showSource()
method console.log(). The
myLogReader.pause(); LogWriter Methods:
excellent FireBug extension to
FireFox supports this method, as myLogReader.resume(); log(sMsg, sCategory,
does the JavaScript console in Instantiate your own LogWriter to write log messages categorized sSource)
Apple's Safari browser. Enable this by their source:
Categories
feature using Logger's enableBrowserConsole() method. MyClass.prototype.myLogWriter = new (Pass in other
YAHOO.widget.LogWriter("MyClass of MyApp"); info
categories to
Dependencies var myInstance = new MyClass(); warn
to add
myInstance.myLogWriter.log("This log message can now error log()
to this list.)
Logger requires the YAHOO object, Dom, and Event; Drag & Drop is be filtered by its source, MyClass."); //"MyClass time
optional. Use in combination with –debug versions of YUI files for of MyApp", the full name of the source, will be window
built-in logging from components. prepended to the actual log message

Das könnte Ihnen auch gefallen