์๋ ํ์ญ๋๊น,
์ต์ phantomjs 1 9 7์ ์ฌ์ฉํ์ฌ console.err์ ์ฌ์ฉํ์ฌ stderr์ ์ธ ์ ์์ต๋๋ค.
ํ๋ฐํธ ์๋ ์คํฌ๋ฆฝํธ์์
throw "some errors";
phantomjs ์คํฌ๋ฆฝํธ์์
page.onConsoleMessage = function(msg, lineNum, sourceId) {
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
};
page.onError = function(msg, trace) {
var msgStack = ['ERROR: ' + msg];
if (trace && trace.length) {
msgStack.push('TRACE:');
trace.forEach(function(t) {
msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function + '")' : ''));
});
}
console.error(msgStack.join('\n'));
};
์ด๊ฒ์ ์๋ํฉ๋๋ค
var phantomjsprocess = require('child_process').execFile(phantomjs.path, childArgs);
phantomjsprocess.stdout
.on('data', function (data) {
grunt.verbose.writeln(data.trim());
})
// having some difficuties to pass phantomjs errors to stderr, so listens to stdout for errors
.on('data', function (data) {
if( data.match(/^(ERROR: )/) ){
grunt.log.writeln(data.trim());
}
});
์ด๊ฒ์ ๊ทธ๋ ์ง ์๊ฑฐ๋ ๊ทธ๋ ์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค.
var phantomjsprocess = require('child_process').execFile(phantomjs.path, childArgs);
phantomjsprocess.stderr
.on('data', function (data) {
grunt.log.writeln(data.trim());
});
๋๋ ๋ฌธ์ # 10232๋ฅผ ์ฝ์์ง๋ง ์ ํํ ๋ด ๋ฌธ์ ์ด์ง๋ง ์ง๊ธ๊น์ง๋ ์๋ํ์ง ์์ต๋๋ค.
ํํธ๊ฐ ์๋์?
๊ฐ์ฌ ํด์.
https://github.com/ariya/phantomjs/issues/10150์ ๋ณต์ ๋ณธ์ผ๋ก ์ข ๋ฃ
์ ๋์ณค๋ค์ ์ฃ์กํฉ๋๋ค... ์ง์ ํด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
๋ค์ ๋ถ๋ค์ ์ํด,
์ด ์ค๋ํซ์ phantomjs ๋ํผ์ ์ถ๊ฐํฉ๋๋ค.
console.error = function () {
require("system").stderr.write(Array.prototype.join.call(arguments, ' ') + '\n');
};
๊ทธ๋ฐ ๋ค์ ์์ ํ๋ก์ธ์ค์ stderr์ ๋ฃ์ต๋๋ค.
phantomJS1.9์์ ํ ์คํธ๋์์ต๋๋ค. 7@์ฐ๋ถํฌ13
๋งค๋ ฅ์ฒ๋ผ ์๋ํฉ๋๋ค!
@maboiteaspam ๋๋ ๋น์ ์ ์ค ๋ํซ์ ํ์ณ์ console.error์์ ๊ธฐ๋ณธ์ ์ผ๋ก stderr์ ๋ํด https://github.com/sotownsend/BooJS ์ ๋์ก์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ ๋์ณค๋ค์ ์ฃ์กํฉ๋๋ค... ์ง์ ํด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
๋ค์ ๋ถ๋ค์ ์ํด,
์ด ์ค๋ํซ์ phantomjs ๋ํผ์ ์ถ๊ฐํฉ๋๋ค.
๊ทธ๋ฐ ๋ค์ ์์ ํ๋ก์ธ์ค์ stderr์ ๋ฃ์ต๋๋ค.
phantomJS1.9์์ ํ ์คํธ๋์์ต๋๋ค. 7@์ฐ๋ถํฌ13
๋งค๋ ฅ์ฒ๋ผ ์๋ํฉ๋๋ค!