2
YUI 3.13.0 (build 508226d)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('yui-log', function (Y, NAME) {
11
* Provides console log capability and exposes a custom event for
12
* console implementations. This module is a `core` YUI module,
13
* <a href="../classes/YUI.html#method_log">it's documentation is located under the YUI class</a>.
21
UNDEFINED = 'undefined',
28
* If the 'debug' config is true, a 'yui:log' event will be
29
* dispatched, which the Console widget and anything else
30
* can consume. If the 'useBrowserConsole' config is true, it will
31
* write to the browser console if available. YUI-specific log
32
* messages will only be present in the -debug versions of the
33
* JS files. The build system is supposed to remove log statements
34
* from the raw and minified versions of the files.
38
* @param {String} msg The message to log.
39
* @param {String} cat The log category for the message. Default
40
* categories are "info", "warn", "error", time".
41
* Custom categories can be used as well. (opt).
42
* @param {String} src The source of the the message (opt).
43
* @param {boolean} silent If true, the log event won't fire.
44
* @return {YUI} YUI instance.
46
INSTANCE.log = function(msg, cat, src, silent) {
47
var bail, excl, incl, m, f, minlevel,
50
publisher = (Y.fire) ? Y : YUI.Env.globalEvents;
51
// suppress log message if the config is off or the event stack
52
// or the event call stack contains a consumer of the yui:log event
54
// apply source filters
56
if (typeof src !== "undefined") {
59
if (incl && !(src in incl)) {
61
} else if (incl && (src in incl)) {
63
} else if (excl && (src in excl)) {
67
// Determine the current minlevel as defined in configuration
68
Y.config.logLevel = Y.config.logLevel || 'debug';
69
minlevel = LEVELS[Y.config.logLevel.toLowerCase()];
71
if (cat in LEVELS && LEVELS[cat] < minlevel) {
72
// Skip this message if the we don't meet the defined minlevel
77
if (c.useBrowserConsole) {
78
m = (src) ? src + ': ' + msg : msg;
79
if (Y.Lang.isFunction(c.logFn)) {
80
c.logFn.call(Y, msg, cat, src);
81
} else if (typeof console !== UNDEFINED && console.log) {
82
f = (cat && console[cat] && (cat in LEVELS)) ? cat : 'log';
84
} else if (typeof opera !== UNDEFINED) {
89
if (publisher && !silent) {
91
if (publisher === Y && (!publisher.getEvent(LOGEVENT))) {
92
publisher.publish(LOGEVENT, {
97
publisher.fire(LOGEVENT, {
110
* Write a system message. This message will be preserved in the
111
* minified and raw versions of the YUI files, unlike log statements.
114
* @param {String} msg The message to log.
115
* @param {String} cat The log category for the message. Default
116
* categories are "info", "warn", "error", time".
117
* Custom categories can be used as well. (opt).
118
* @param {String} src The source of the the message (opt).
119
* @param {boolean} silent If true, the log event won't fire.
120
* @return {YUI} YUI instance.
122
INSTANCE.message = function() {
123
return INSTANCE.log.apply(INSTANCE, arguments);
127
}, '3.13.0', {"requires": ["yui-base"]});