그란트는 로그 메시지 작성을위한 grunt.log 개체를 사용합니다. sources에서 볼 수 있듯이 이제 grunt.log
은 별도의 모듈 grunt-legacy-log
에 구현되었습니다. 어쨌든, 우리는 Gruntfile 내부에서이 메소드들을 재정 의하여 우리가 원하는 로그로 어떤 액션을 수행 할 수 있습니다.
첫째, NPM을 통해 grunt-legacy-log
를 설치
npm install grunt-legacy-log
그런 다음,이 같은
grunt.log
을 재정의 : 그것 뿐이다
module.exports = function (grunt) {
var Log = require('grunt-legacy-log').Log;
var log = new Log({grunt: grunt});
function LogExtended() {
for (var methodName in log) {
if (typeof log[methodName] === 'function') {
this[methodName] = (function (methodName) {
return function() {
var args = Array.prototype.slice.call(arguments, 0);
// Filter methods yourself here to collect data
// and perform any actions like POST to server
console.log(methodName, args);
// This will call original grunt.log method
return log[methodName].apply(log, args);
}
}(methodName));
}
}
}
LogExtended.prototype = log;
grunt.log = new LogExtended();
grunt.initConfig({ .. });
};
합니다. 희망하는 데이터를 수집하고 직접 작업을 작성할 수 있기를 바랍니다.