index.js 586 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. /*
  3. Initial code from https://github.com/gulpjs/gulp-util/blob/v3.0.6/lib/log.js
  4. */
  5. var chalk = require('chalk');
  6. var timestamp = require('time-stamp');
  7. function getTimestamp(){
  8. return '['+chalk.grey(timestamp('HH:mm:ss'))+']';
  9. }
  10. function log(){
  11. var time = getTimestamp();
  12. process.stdout.write(time + ' ');
  13. console.log.apply(console, arguments);
  14. return this;
  15. }
  16. function error(){
  17. var time = getTimestamp();
  18. process.stderr.write(time + ' ');
  19. console.error.apply(console, arguments);
  20. return this;
  21. }
  22. module.exports = log;
  23. module.exports.error = error;