Logger Widget :: Writing Logs

Writing Log Messages From Your Code

In this example, we instanatiate a simple LogReader to display log messages. We use the global method YAHOO.log() to write simple messages, and we also instantiate a LogWriter instance to write messages from a custom-named source.

(not supported in Opera, Safari)

Sample Code

CSS:

    No CSS styles were defined.
    

Markup:

    No markup was defined.
    

JavaScript:

    // Instantiate a logreader and a logwriter
    myLogReader = new YAHOO.widget.LogReader(null,{top:"50%",right:"10px"});
    myLogWriter = new YAHOO.widget.LogWriter("myWriter");

    // You can call the global function YAHOO.log() anytime, anywhere
    YAHOO.log("Yahoo! is great"); // defaults to type "info"
    YAHOO.log("Here is a warning", "warn");
    YAHOO.log("Some error has occurred", "error");
    YAHOO.log("Use timers to profile your code", "time");

    myLogWriter.log("something","info");
    myLogWriter.log("something","warn");
    myLogWriter.log("something","error");
    myLogWriter.log("something","time");
    myLogWriter.log("something","custom");