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
LogReader collapse button element.
_btnPause
- private HTMLElement
LogReader pause button element.
_buffer
- private Object[]
Buffer of log message objects for batch output.
Array of filters for log message categories.
Number of log messages output to console.
Default Value: 0
_elBtns
- private HTMLElement
LogReader buttons container element.
Container element for LogReader category filter checkboxes.
LogReader collapse element.
_elConsole
- private HTMLElement
LogReader console element.
LogReader container element.
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.
Container element for LogReader source filter checkboxes.
Hash of filters and their related checkbox elements.
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.
Array of filters for log message sources.
_timeout
- private Number
Batched output timeout ID.
_title
- private HTMLElement
LogReader title header element.
Template used for innerHTML of compact entry output.
Default Value: "
{label}{totalTime}ms (+{elapsedTime}) {localTime}: {sourceAndDetail}: {message}
"
Public member to access CSS bottom position of the LogReader container.
Enables draggable LogReader if DragDrop Utility is present.
Default Value: true
Node template for the log entries
Default Value: PRE.yui-log-entry element
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
Public member to access CSS font size of the LogReader container.
Whether or not the footer UI is enabled for the LogReader.
Default Value: true
Public member to access CSS height of the LogReader container.
True when LogReader is in a collapsed state, false otherwise.
Default Value: false
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.
Whether or not LogReader is enabled to output log messages.
Default Value: true
Whether or not newest message is printed on top.
Output timeout buffer in milliseconds.
Default Value: 100
Public member to access CSS right position of the LogReader container.
Maximum number of messages a LogReader console will display.
Default Value: 500
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.
Template used for innerHTML of verbose entry output.
Default Value: "
{label}{totalTime}ms (+{elapsedTime}) {localTime}:
{sourceAndDetail}
{message}
"
Whether or not output is verbose (more readable). Setting to true will make
output more compact (less readable).
Default Value: true
Public member to access CSS width of the LogReader container.
Methods
private
void
_createCategoryCheckbox
(
sCategory
)
Creates the UI for a category filter in the LogReader footer element.
- Parameters:
-
sCategory
<String>
Category name.
- Returns:
void
private
void
_createSourceCheckbox
(
sSource
)
Creates a checkbox in the LogReader footer element to filter by source.
- Parameters:
-
sSource
<String>
Source name.
- Returns:
void
private
void
_filterLogs
(
)
Reprints all log messages in the stack through filters.
private
void
_initCategories
(
)
Initializes category filters.
private
void
_initConsoleEl
(
)
Initializes the console element.
private
void
_initContainerEl
(
elContainer
)
Initializes the primary container element.
- Parameters:
-
elContainer
<HTMLElement>
Container element by reference or string ID.
- Returns:
void
private
void
_initDragDrop
(
)
Initializes Drag and Drop on the header element.
private
void
_initFooterEl
(
)
Initializes the footer element.
private
void
_initHeaderEl
(
)
Initializes the header element.
private
void
_initSources
(
)
Initializes source filters.
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
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
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
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
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
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
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
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
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
private
void
_printBuffer
(
)
Sends buffer of log messages to output and clears buffer.
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
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.
void
collapse
(
)
Collapses UI of LogReader. Logging functionality is not disrupted.
void
expand
(
)
Expands UI of LogReader. Logging functionality is not disrupted.
String[]
getCategories
(
)
Returns array of enabled categories.
- Returns:
String[]
- Array of enabled categories.
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.
Date
getLastTime
(
)
Gets timestamp of the last log.
- Returns:
Date
- Timestamp of the last log.
Array
getSources
(
)
Returns array of enabled sources.
- Returns:
Array
- Array of enabled sources.
void
hide
(
)
Hides UI of LogReader. Logging functionality is not disrupted.
void
hideCategory
(
Category
)
Hides log messages associated with given category.
- Parameters:
-
Category
<String>
name.
- Returns:
void
void
hideSource
(
Source
)
Hides log messages associated with given source.
- Parameters:
-
Source
<String>
name.
- Returns:
void
private
void
html2Text
(
sHtml
)
Converts input chars "<", ">", and "&" to HTML entities.
- Parameters:
-
sHtml
<String>
String to convert.
- Returns:
void
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.
void
resume
(
)
Resumes output of log messages, including outputting any log messages that
have been saved to buffer while paused.
void
setTitle
(
sTitle
)
Updates title to given string.
- Parameters:
-
sTitle
<String>
New title.
- Returns:
void
void
show
(
)
Shows UI of LogReader. Logging functionality is not disrupted.
void
showCategory
(
Category
)
Shows log messages associated with given category.
- Parameters:
-
Category
<String>
name.
- Returns:
void
void
showSource
(
Source
)
Shows log messages associated with given source.
- Parameters:
-
Source
<String>
name.
- Returns:
void
String
toString
(
)
Public accessor to the unique name of the LogReader instance.
- Returns:
String
- Unique name of the LogReader instance.