# Yahoo! UI Library

### Logger Widget 2.5.0

Yahoo! UI Library > logger > YAHOO.widget.LogReader

Show Private Show Protected

## Class YAHOO.widget.LogReader

The LogReader class provides UI to read messages logged to YAHOO.widget.Logger.

### Constructor

YAHOO.widget.LogReader `( elContainer , oConfigs )`

Parameters:
  `elContainer <HTMLElement>` (optional) DOM element reference of an existing DIV.
  `elContainer <String>` (optional) String ID of an existing DIV.
  `oConfigs <Object>` (optional) Object literal of configuration params.

### Properties

#### _btnClear `- private HTMLElement`

Clear button element.

#### _btnCollapse `- private HTMLElement`

LogReader collapse button element.

#### _btnPause `- private HTMLElement`

LogReader pause button element.

#### _buffer `- private Object[]`

Buffer of log message objects for batch output.

#### _categoryFilters `- private String[]`

Array of filters for log message categories.

#### _consoleMsgCount `- private Number`

Number of log messages output to console.
Default Value: 0

#### _elBtns `- private HTMLElement`

LogReader buttons container element.

#### _elCategoryFilters `- private HTMLElement`

Container element for LogReader category filter checkboxes.

#### _elCollapse `- private HTMLElement`

LogReader collapse element.

#### _elConsole `- private HTMLElement`

LogReader console element.

#### _elContainer `- private HTMLElement`

LogReader container element.

#### _elDefaultContainer `- private HTMLElement`

A class member shared by all LogReaders if a container needs to be created during instantiation. Will be null if a container element never needs to be created on the fly, such as when the implementer passes in their own element.

#### _elFt `- private HTMLElement`

LogReader footer element.

#### _elHd `- private HTMLElement`

LogReader header element.

#### _elSourceFilters `- private HTMLElement`

Container element for LogReader source filter checkboxes.

#### _filterCheckboxes `- private Object`

Hash of filters and their related checkbox elements.

#### _lastTime `- private Date`

Date of last output log message.

#### _memberName `- private static Number`

Internal class member to index multiple LogReader instances.
Default Value: 0

#### _sName `- private String`

Name of LogReader instance.

#### _sourceFilters `- private String[]`

Array of filters for log message sources.

#### _timeout `- private Number`

Batched output timeout ID.

#### _title `- private HTMLElement`

LogReader title header element.

#### bottom `- String`

Public member to access CSS bottom position of the LogReader container.

#### draggable `- Boolean`

Enables draggable LogReader if DragDrop Utility is present.
Default Value: true

#### fontSize `- String`

Public member to access CSS font size of the LogReader container.

#### footerEnabled `- Boolean`

Whether or not the footer UI is enabled for the LogReader.
Default Value: true

#### height `- String`

Public member to access CSS height of the LogReader container.

#### isCollapsed `- Boolean`

True when LogReader is in a collapsed state, false otherwise.
Default Value: false

#### isPaused `- Boolean`

True when LogReader is in a paused state, false otherwise.
Default Value: false

#### left `- String`

Public member to access CSS left position of the LogReader container.

#### logReaderEnabled `- Boolean`

Whether or not LogReader is enabled to output log messages.
Default Value: true

#### newestOnTop `- Boolean`

Whether or not newest message is printed on top.

#### outputBuffer `- Number`

Output timeout buffer in milliseconds.
Default Value: 100

#### right `- String`

Public member to access CSS right position of the LogReader container.

#### thresholdMax `- Number`

Maximum number of messages a LogReader console will display.
Default Value: 500

#### thresholdMin `- Number`

When a LogReader console reaches its thresholdMax, it will clear out messages and print out the latest thresholdMin number of messages.
Default Value: 100

#### top `- String`

Public member to access CSS top position of the LogReader container.

#### verboseOutput `- Boolean`

Whether or not output is verbose (more readable). Setting to true will make output more compact (less readable).
Default Value: true

#### width `- String`

Public member to access CSS width of the LogReader container.

### Methods

#### _createCategoryCheckbox

`private void _createCategoryCheckbox ( sCategory )`
Creates the UI for a category filter in the LogReader footer element.

Parameters:
  `sCategory <String>` Category name.

Returns: `void`

#### _createSourceCheckbox

`private void _createSourceCheckbox ( sSource )`
Creates a checkbox in the LogReader footer element to filter by source.

Parameters:
  `sSource <String>` Source name.

Returns: `void`

#### _filterLogs

`private void _filterLogs ( )`
Reprints all log messages in the stack through filters.

Returns: `void`

#### _initCategories

`private void _initCategories ( )`
Initializes category filters.

Returns: `void`

#### _initConsoleEl

`private void _initConsoleEl ( )`
Initializes the console element.

Returns: `void`

#### _initContainerEl

`private void _initContainerEl ( elContainer )`
Initializes the primary container element.

Parameters:
  `elContainer <HTMLElement>` Container element by reference or string ID.

Returns: `void`

#### _initDragDrop

`private void _initDragDrop ( )`
Initializes Drag and Drop on the header element.

Returns: `void`

#### _initFooterEl

`private void _initFooterEl ( )`
Initializes the footer element.

Returns: `void`

#### _initHeaderEl

`private void _initHeaderEl ( )`
Initializes the header element.

Returns: `void`

#### _initSources

`private void _initSources ( )`
Initializes source filters.

Returns: `void`

#### _onCategoryCreate

`private void _onCategoryCreate ( sType , aArgs , oSelf )`
Handles Logger's categoryCreateEvent.

Parameters:
  `sType <String>` The event.
  `aArgs <Object[]>` Data passed from event firer.
  `oSelf <Object>` The LogReader instance.

Returns: `void`

#### _onCheckCategory

`private void _onCheckCategory ( v , oSelf )`
Handles check events on the category filter checkboxes.

Parameters:
  `v <HTMLEvent>` The click event.
  `oSelf <Object>` The LogReader instance.

Returns: `void`

#### _onCheckSource

`private void _onCheckSource ( v , oSelf )`
Handles check events on the category filter checkboxes.

Parameters:
  `v <HTMLEvent>` The click event.
  `oSelf <Object>` The LogReader instance.

Returns: `void`

#### _onClickClearBtn

`private void _onClickClearBtn ( v , oSelf )`
Handles click events on the clear button.

Parameters:
  `v <HTMLEvent>` The click event.
  `oSelf <Object>` The LogReader instance.

Returns: `void`

#### _onClickCollapseBtn

`private void _onClickCollapseBtn ( v , oSelf )`
Handles click events on the collapse button.

Parameters:
  `v <HTMLEvent>` The click event.
  `oSelf <Object>` The LogReader instance

Returns: `void`

#### _onClickPauseBtn

`private void _onClickPauseBtn ( v , oSelf )`
Handles click events on the pause button.

Parameters:
  `v <HTMLEvent>` The click event.
  `oSelf <Object>` The LogReader instance.

Returns: `void`

#### _onNewLog

`private void _onNewLog ( sType , aArgs , oSelf )`
Handles Logger's newLogEvent.

Parameters:
  `sType <String>` The event.
  `aArgs <Object[]>` Data passed from event firer.
  `oSelf <Object>` The LogReader instance.

Returns: `void`

#### _onReset

`private void _onReset ( sType , aArgs , oSelf )`
Handles Logger's resetEvent.

Parameters:
  `sType <String>` The event.
  `aArgs <Object[]>` Data passed from event firer.
  `oSelf <Object>` The LogReader instance.

Returns: `void`

#### _onSourceCreate

`private void _onSourceCreate ( sType , aArgs , oSelf )`
Handles Logger's sourceCreateEvent.

Parameters:
  `sType <String>` The event.
  `aArgs <Object[]>` Data passed from event firer.
  `oSelf <Object>` The LogReader instance.

Returns: `void`

#### _printBuffer

`private void _printBuffer ( )`
Sends buffer of log messages to output and clears buffer.

Returns: `void`

#### _printToConsole

`private void _printToConsole ( aEntries )`
Cycles through an array of log messages, and outputs each one to the console if its category has not been filtered out.

Parameters:
  `aEntries <Object[]>` Array of LogMsg objects to output to console.

Returns: `void`

#### clearConsole

`void clearConsole ( )`
Does not delete any log messages, but clears all printed log messages from the console. Log messages will be printed out again if user re-filters. The static method YAHOO.widget.Logger.reset() should be called in order to actually delete log messages.

Returns: `void`

#### collapse

`void collapse ( )`
Collapses UI of LogReader. Logging functionality is not disrupted.

Returns: `void`

#### expand

`void expand ( )`
Expands UI of LogReader. Logging functionality is not disrupted.

Returns: `void`

#### formatMsg

`String formatMsg ( oLogMsg )`
Formats message string to HTML for output to console.

Parameters:
  `oLogMsg <Object>` Log message object.

Returns: `String`
  HTML-formatted message for output to console.

#### getCategories

`String[] getCategories ( )`
Returns array of enabled categories.

Returns: `String[]`
  Array of enabled categories.

#### getCheckbox

`Array getCheckbox ( Category )`
Returns related checkbox element for given filter (i.e., category or source).

Parameters:
  `Category <String>` or source name.

Returns: `Array`
  Array of all filter checkboxes.

#### getLastTime

`Date getLastTime ( )`
Gets timestamp of the last log.

Returns: `Date`
  Timestamp of the last log.

#### getSources

`Array getSources ( )`
Returns array of enabled sources.

Returns: `Array`
  Array of enabled sources.

#### hide

`void hide ( )`
Hides UI of LogReader. Logging functionality is not disrupted.

Returns: `void`

#### hideCategory

`void hideCategory ( Category )`
Hides log messages associated with given category.

Parameters:
  `Category <String>` name.

Returns: `void`

#### hideSource

`void hideSource ( Source )`
Hides log messages associated with given source.

Parameters:
  `Source <String>` name.

Returns: `void`

#### html2Text

`private void html2Text ( sHtml )`
Converts input chars "<", ">", and "&" to HTML entities.

Parameters:
  `sHtml <String>` String to convert.

Returns: `void`

#### pause

`void pause ( )`
Pauses output of log messages. While paused, log messages are not lost, but get saved to a buffer and then output upon resume of LogReader.

Returns: `void`

#### resume

`void resume ( )`
Resumes output of log messages, including outputting any log messages that have been saved to buffer while paused.

Returns: `void`

#### setTitle

`void setTitle ( sTitle )`
Updates title to given string.

Parameters:
  `sTitle <String>` New title.

Returns: `void`

#### show

`void show ( )`
Shows UI of LogReader. Logging functionality is not disrupted.

Returns: `void`

#### showCategory

`void showCategory ( Category )`
Shows log messages associated with given category.

Parameters:
  `Category <String>` name.

Returns: `void`

#### showSource

`void showSource ( Source )`
Shows log messages associated with given source.

Parameters:
  `Source <String>` name.

Returns: `void`

#### toString

`String toString ( )`
Public accessor to the unique name of the LogReader instance.

Returns: `String`
  Unique name of the LogReader instance.

Copyright © 2007 Yahoo! Inc. All rights reserved.