Skip to content

Commit

Permalink
Use logFn configuration to logging (fixes yui#325)
Browse files Browse the repository at this point in the history
`util.error` have been deprecated on Node v0.12, but YUI still uses it. It uses
`logFn` configuration of YUI to avoid this problem. Basically, it'll uses
`console.*` functions instead.

Fix yui#325.
  • Loading branch information
okuryu committed Mar 28, 2015
1 parent 0429a37 commit 05224f7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ var YUI = require('yui' + (debug ? '/debug' : '')).YUI,
fs = require('graceful-fs'),
metaPath = path.join(__dirname, '../', 'package.json');

function log (message, level) {
if (!message || !level || typeof console[level] !== 'function') {
return;
}
console[level]('%s: %s', level, message);
}

process.on('uncaughtException', function (msg) {
var meta = JSON.parse(fs.readFileSync(metaPath)),
Expand All @@ -44,6 +50,7 @@ process.on('uncaughtException', function (msg) {

inst.applyConfig({
debug: true,
logFn: log,
useColor: useColor
});

Expand Down Expand Up @@ -100,6 +107,7 @@ var Y = YUI({
attribute: true,
handlebars: true
},
logFn: log,
useSync: true
}).use('utils', 'docparser', 'yuidoc', 'doc-builder', 'docview', 'files', 'help', 'options', 'server', 'project');

Expand Down

3 comments on commit 05224f7

@franck34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi

  • colors are lost
  • object are displayed as [Object object]

@okuryu
Copy link
Owner Author

@okuryu okuryu commented on 05224f7 Mar 28, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • colors are lost

Yup, I think colors isn't high requirement for YUIDoc, do you have any concern?

  • object are displayed as [Object object]

Okay, I'll do.

@franck34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no colors are not imporant ;)

for object, i've used simply JSON.stringify()

@okuryu thanks for the fix !

Please sign in to comment.