2
YUI 3.10.3 (build 2fb5187)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('yui-log-nodejs', function (Y, NAME) {
10
var sys = require(process.binding('natives').util ? 'util' : 'sys'),
14
var stdio = require("stdio");
15
hasColor = stdio.isStderrATTY();
20
Y.config.useColor = hasColor;
22
Y.consoleColor = function(str, num) {
23
if (!this.config.useColor) {
29
return "\u001b[" + num +"m" + str + "\u001b[0m";
33
var logFn = function(str, t, m) {
34
var id = '', lvl, mLvl;
36
id = '[' + this.id + ']:';
39
m = (m) ? this.consoleColor(' (' + m.toLowerCase() + '):', 35) : '';
45
if ((typeof str === 'object') || str instanceof Array) {
48
if (str.tagName || str._yuid || str._query) {
51
str = sys.inspect(str);
59
mLvl = ((str) ? '' : 31);
60
t = t+''; //Force to a string..
61
switch (t.toLowerCase()) {
72
if (typeof str === 'string') {
73
if (str && str.indexOf("\n") !== -1) {
78
// output log messages to stderr
79
sys.error(this.consoleColor(t.toLowerCase() + ':', lvl) + m + ' ' + this.consoleColor(str, mLvl));
82
if (!Y.config.logFn) {
83
Y.config.logFn = logFn;