YUI 3.x Home -

YUI Library Examples: Console: Creating a universal Console

Note: This is YUI 3.x. Looking for YUI 2.x?

Console: Creating a universal Console

In this example, the Console's logSource configuration is set to Y.Global, an EventTarget shared by all YUI instances.

Two YUI instances are created with different configurations and module inclusions. Each YUI instance is configured to request the module-debug.js version of its modules and dependencies and filter out all but specific log sources using the logInclude config property.

The universal Console is instantiated and rendered inside the first YUI instance.

YUI #1: Slider

YUI #2: Animation

HIDE ME

Multiple YUI instances

Each YUI instance is its own sandbox. You can create as many YUI instances on a page as you want or need. The variables, module configurations and instances are kept inside that instance unless you expressly expose them via a global variable.

Listening to Y.Global

To address debugging such an environment, Console can be configured to listen for log messages across all YUI instances by setting the Console instance's logSource configuration to Y.Global.

We'll insert the Console creation into the first YUI instance's callback. By default, Console will only listen to log messages originating from its own YUI instance sandbox.

Full Code Listing

Markup

JavaScript

CSS

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings