/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/**
* The LogWriter class provides a mechanism to log messages through
* YAHOO.widget.Logger from a named source.
*
* @class LogWriter
* @constructor
* @param sSource {String} Source of LogWriter instance.
*/
YAHOO.widget.LogWriter = function(sSource) {
if(!sSource) {
YAHOO.log("Could not instantiate LogWriter due to invalid source.",
"error", "LogWriter");
return;
}
this._source = sSource;
};
/////////////////////////////////////////////////////////////////////////////
//
// Public methods
//
/////////////////////////////////////////////////////////////////////////////
/**
* Public accessor to the unique name of the LogWriter instance.
*
* @method toString
* @return {String} Unique name of the LogWriter instance.
*/
YAHOO.widget.LogWriter.prototype.toString = function() {
return "LogWriter " + this._sSource;
};
/**
* Logs a message attached to the source of the LogWriter.
* Note: the LogReader adds the message and category to the DOM as HTML.
*
* @method log
* @param sMsg {HTML} The log message.
* @param sCategory {HTML} Category name.
*/
YAHOO.widget.LogWriter.prototype.log = function(sMsg, sCategory) {
YAHOO.widget.Logger.log(sMsg, sCategory, this._source);
};
/**
* Public accessor to get the source name.
*
* @method getSource
* @return {String} The LogWriter source.
*/
YAHOO.widget.LogWriter.prototype.getSource = function() {
return this._source;
};
/**
* Public accessor to set the source name.
*
* @method setSource
* @param sSource {String} Source of LogWriter instance.
*/
YAHOO.widget.LogWriter.prototype.setSource = function(sSource) {
if(!sSource) {
YAHOO.log("Could not set source due to invalid source.", "error", this.toString());
return;
}
else {
this._source = sSource;
}
};
/////////////////////////////////////////////////////////////////////////////
//
// Private member variables
//
/////////////////////////////////////////////////////////////////////////////
/**
* Source of the LogWriter instance.
*
* @property _source
* @type String
* @private
*/
YAHOO.widget.LogWriter.prototype._source = null;