#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# Plugin.ConsoleFilters Class

Defined in: `console-filters/js/console-filters.js:1`
Module: console-filters

Provides Plugin.ConsoleFilters plugin class.

This plugin adds the ability to control which Console entries display by filtering on category and source. Two groups of checkboxes are added to the Console footer, one for categories and the other for sources. Only those messages that match a checked category or source are displayed.

- Index
- Methods
- Properties
- Attributes

## Item Index

### Methods

- _afterCacheLimitChange
- _afterCategoryChange
- _afterClearConsole
- _afterSourceChange
- _createCheckbox
- _filterBuffer
- _onCategoryCheckboxClick
- _onEntry
- _onSourceCheckboxClick
- _setCacheLimit
- _uiSetCheckbox
- _validateCategory
- _validateSource
- bindUI
- destructor
- hideCategory
- hideSource
- initializer
- refreshConsole
- renderUI
- showCategory
- showSource
- syncUI

### Properties

- _cacheLimit
- _categories
- _entries
- _sources
- CATEGORIES_TEMPLATE static
- CHROME_CLASSES static
- FILTER_TEMPLATE static
- NAME static
- NS static
- SOURCES_TEMPLATE static

### Attributes

- cacheLimit
- category
- defaultVisibility
- source

## Methods

### `_afterCacheLimitChange`

(

- `e`

)
protected

Defined in `console-filters/js/console-filters.js:317`

Trims the cache of entries to the appropriate new length.

#### Parameters:

- `e` Event

  the attribute change event object

### `_afterCategoryChange`

(

- `e`

)
protected

Defined in `console-filters/js/console-filters.js:238`

Triggers the Console to update if a known category filter changes value (e.g. visible => hidden). Updates the appropriate checkbox's checked state if necessary.

#### Parameters:

- `e` Event

  the attribute change event object

### `_afterClearConsole`

() protected

Defined in `console-filters/js/console-filters.js:228`

Flushes the cached entries after a call to the Console's clearConsole().

### `_afterSourceChange`

(

- `e`

)
protected

Defined in `console-filters/js/console-filters.js:264`

Triggers the Console to update if a known source filter changes value (e.g. visible => hidden). Updates the appropriate checkbox's checked state if necessary.

#### Parameters:

- `e` Event

  the attribute change event object

### `_createCheckbox`

(

- `container`
- `name`

)
protected

Defined in `console-filters/js/console-filters.js:501`

Creates a checkbox and label from the ConsoleFilters.FILTER_TEMPLATE for the provided type and name. The checkbox and label are appended to the container node passes as the first arg.

#### Parameters:

- `container` Node

  the parentNode of the new checkbox and label

- `name` String

  the identifier of the filter

### `_filterBuffer`

() protected

Defined in `console-filters/js/console-filters.js:290`

Flushes the Console's print buffer of any entries that have a category or source that is currently being excluded.

### `_onCategoryCheckboxClick`

(

- `e`

)
protected

Defined in `console-filters/js/console-filters.js:401`

Passes checkbox clicks on to the category attribute.

#### Parameters:

- `e` Event

  the DOM event

### `_onEntry`

(

- `e`

)
protected

Defined in `console-filters/js/console-filters.js:187`

Ensures a filter is set up for any new categories or sources and collects the messages in _entries. If the message is stamped with a category or source that is currently being filtered out, the message will not pass to the Console's print buffer.

#### Parameters:

- `e` Event

  the custom event object

### `_onSourceCheckboxClick`

(

- `e`

)
protected

Defined in `console-filters/js/console-filters.js:419`

Passes checkbox clicks on to the source attribute.

#### Parameters:

- `e` Event

  the DOM event

### `_setCacheLimit`

(

- `v`

)
Number protected

Defined in `console-filters/js/console-filters.js:550`

Setter method for cacheLimit attribute. Basically a validator to ensure numeric input.

#### Parameters:

- `v` Number

  Maximum number of entries

#### Returns:

Number:

### `_uiSetCheckbox`

(

- `type`
- `item`
- `checked`

)
protected

Defined in `console-filters/js/console-filters.js:368`

Updates the checked property of a filter checkbox of the specified type. If no checkbox is found for the input params, one is created.

#### Parameters:

- `type` String

  'category' or 'source'

- `item` String

  the name of the filter (e.g. 'info', 'event')

- `checked` Boolean

  value to set the checkbox's checked property

### `_validateCategory`

(

- `cat`
- `v`

)
protected

Defined in `console-filters/js/console-filters.js:522`

Validates category updates are objects and the subattribute is not too deep.

#### Parameters:

- `cat` String

  the new category:visibility map

- `v` String

  the subattribute path updated

#### Returns:

Boolean

### `_validateSource`

(

- `cat`
- `v`

)
protected

Defined in `console-filters/js/console-filters.js:536`

Validates source updates are objects and the subattribute is not too deep.

#### Parameters:

- `cat` String

  the new source:visibility map

- `v` String

  the subattribute path updated

#### Returns:

Boolean

### `bindUI`

() protected

Defined in `console-filters/js/console-filters.js:154`

Binds to checkbox click events and internal attribute change events to maintain the UI state.

### `destructor`

() protected

Defined in `console-filters/js/console-filters.js:110`

Removes the plugin UI and unwires events.

### `hideCategory`

(

- `cat`

)

Defined in `console-filters/js/console-filters.js:437`

Hides any number of categories from the UI. Convenience method for myConsole.filter.set('category.foo', false); set('category.bar', false); and so on.

#### Parameters:

- `cat` String multiple

  1..n categories to filter out of the UI

### `hideSource`

(

- `src`

)

Defined in `console-filters/js/console-filters.js:469`

Hides any number of sources from the UI. Convenience method for myConsole.filter.set('source.foo', false); set('source.bar', false); and so on.

#### Parameters:

- `src` String multiple

  1..n sources to filter out of the UI

### `initializer`

() protected

Defined in `console-filters/js/console-filters.js:83`

Initialize entries collection and attach listeners to host events and methods.

### `refreshConsole`

()

Defined in `console-filters/js/console-filters.js:334`

Repopulates the Console with entries appropriate to the current filter settings.

### `renderUI`

() protected

Defined in `console-filters/js/console-filters.js:129`

Adds the category and source filter sections to the Console footer.

### `showCategory`

(

- `cat`

)

Defined in `console-filters/js/console-filters.js:453`

Shows any number of categories in the UI. Convenience method for myConsole.filter.set('category.foo', true); set('category.bar', true); and so on.

#### Parameters:

- `cat` String multiple

  1..n categories to allow to display in the UI

### `showSource`

(

- `src`

)

Defined in `console-filters/js/console-filters.js:485`

Shows any number of sources in the UI. Convenience method for myConsole.filter.set('source.foo', true); set('source.bar', true); and so on.

#### Parameters:

- `src` String multiple

  1..n sources to allow to display in the UI

### `syncUI`

()

Defined in `console-filters/js/console-filters.js:170`

Updates the UI to be in accordance with the current state of the plugin.

## Properties

### `_cacheLimit`

Number protected

Defined in `console-filters/js/console-filters.js:55`

Maximum number of entries to store in the message cache.

Default: Infinity

### `_categories`

Node protected

Defined in `console-filters/js/console-filters.js:65`

The container node created to house the category filters.

### `_entries`

Array protected

Defined in `console-filters/js/console-filters.js:43`

Collection of all log messages passed through since the plugin's instantiation. This holds all messages regardless of filter status. Used as a single source of truth for repopulating the Console body when filters are changed.

### `_sources`

Node protected

Defined in `console-filters/js/console-filters.js:74`

The container node created to house the source filters.

### `CATEGORIES_TEMPLATE`

String static

Defined in `console-filters/js/console-filters.js:591`

Markup template used to create the container for the category filters.

### `CHROME_CLASSES`

Object protected static

Defined in `console-filters/js/console-filters.js:628`

Classnames used by the templates when creating nodes.

### `FILTER_TEMPLATE`

String static

Defined in `console-filters/js/console-filters.js:611`

Markup template used to create the category and source filter checkboxes.

### `NAME`

String static

Defined in `console-filters/js/console-filters.js:571`

Plugin name.

Default: 'consoleFilters'

### `NS`

String static

Defined in `console-filters/js/console-filters.js:581`

The namespace hung off the host object that this plugin will inhabit.

Default: 'filter'

### `SOURCES_TEMPLATE`

String static

Defined in `console-filters/js/console-filters.js:601`

Markup template used to create the container for the source filters.

## Attributes

### `cacheLimit`

Number

Defined in `console-filters/js/console-filters.js:702`

Maximum number of entries to store in the message cache. Use this to limit the memory footprint in environments with heavy log usage. By default, there is no limit (Number.POSITIVE_INFINITY).

Default: Number.POSITIVE_INFINITY

#### Fires event `cacheLimitChange`

Fires when the value for the configuration attribute `cacheLimit` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `category`

Object

Defined in `console-filters/js/console-filters.js:658`

Map of entry categories to their visibility status. Update a particular category's visibility by setting the subattribute to true (visible) or false (hidden).

For example, yconsole.filter.set('category.info', false) to hide log entries with the category/logLevel of 'info'.

Similarly, yconsole.filter.get('category.warn') will return a boolean indicating whether that category is currently being included in the UI.

Unlike the YUI instance configuration's logInclude and logExclude properties, filtered entries are only hidden from the UI, but can be made visible again.

#### Fires event `categoryChange`

Fires when the value for the configuration attribute `category` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `defaultVisibility`

Boolean

Defined in `console-filters/js/console-filters.js:646`

Default visibility applied to new categories and sources.

Default: true

#### Fires event `defaultVisibilityChange`

Fires when the value for the configuration attribute `defaultVisibility` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `source`

Object

Defined in `console-filters/js/console-filters.js:684`

Map of entry sources to their visibility status. Update a particular sources's visibility by setting the subattribute to true (visible) or false (hidden).

For example, yconsole.filter.set('sources.slider', false) to hide log entries originating from Y.Slider.

#### Fires event `sourceChange`

Fires when the value for the configuration attribute `source` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.