# Yahoo! UI Library

### Logger Widget 2.8.2r1

Yahoo! UI Library > logger > LogReader
Search:
Filters
Show Private Show Protected Show Deprecated

## Class LogReader

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

### Constructor

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.

#### autoRender - `{Boolean}`

Render the LogReader immediately upon instantiation. If set to false, you must call myLogReader.render() to generate the UI.
Default Value: true

#### BASIC_TEMPLATE - `static object`

Template used for innerHTML of compact entry output.
Default Value: "<p><span class='{category}'>{label}</span>{totalTime}ms (+{elapsedTime}) {localTime}: {sourceAndDetail}: {message}</p>"

#### 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

#### ENTRY_TEMPLATE - `static {HTMLElement}`

Node template for the log entries
Default Value: `pre` element with class yui-log-entry

#### entryFormat - `String`

Custom output format for log messages. Defaults to null, which falls back to verboseOutput param deciding between LogReader.VERBOSE_TEMPLATE and LogReader.BASIC_TEMPLATE. Use bracketed place holders to mark where message info should go. Available place holder names include:

- category
- label
- sourceAndDetail
- message
- localTime
- elapsedTime
- totalTime

Default Value: null

#### 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.

#### VERBOSE_TEMPLATE - `static object`

Template used for innerHTML of verbose entry output.
Default Value: "<p><span class='{category}'>{label}</span>{totalTime}ms (+{elapsedTime}) {localTime}:</p><p>{sourceAndDetail}</p><p>{message}</p>"

#### 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.

#### _createSourceCheckbox

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

Parameters:
  `sSource <String>` Source name.

#### _filterLogs

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

#### _init

`protected void _init ( container , config )`
Initializes the instance's message buffer, start time, etc

Parameters:
  `container <String|HTMLElement>` (optional) the render target
  `config <Object>` (optional) instance configuration

#### _initCategories

`private void _initCategories ( )`
Initializes category filters.

#### _initConsoleEl

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

#### _initContainerEl

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

#### _initDragDrop

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

#### _initFooterEl

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

#### _initHeaderEl

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

#### _initSources

`private void _initSources ( )`
Initializes source filters.

#### _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.

#### _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.

#### _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.

#### _onClickClearBtn

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

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

#### _onClickCollapseBtn

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

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

#### _onClickPauseBtn

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

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

#### _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.

#### _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.

#### _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.

#### _printBuffer

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

#### _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.

#### 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.

#### collapse

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

#### destroy

`void destroy ( )`
Removes the UI from the DOM entirely and detaches all event listeners. Implementers should note that Logger will still accumulate messages.

#### expand

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

#### 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.

#### hideCategory

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

Parameters:
  `Category <String>` name.

#### hideSource

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

Parameters:
  `Source <String>` name.

#### html2Text

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

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

#### 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.

#### render

`void render ( )`
Adds the UI to the DOM, attaches event listeners, and bootstraps initial UI state.

#### resume

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

#### setTitle

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

Parameters:
  `sTitle <String>` New title.

#### show

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

#### showCategory

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

Parameters:
  `Category <String>` name.

#### showSource

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

Parameters:
  `Source <String>` name.

#### toString

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

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

Copyright © 2010 Yahoo! Inc. All rights reserved.