all files / lib/ log.js

83.33% Statements 15/18
50% Branches 2/4
83.33% Functions 5/6
83.33% Lines 15/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                              
const chalk = require('chalk');
 
const _ = module.exports = {};
 
let logLevel = 'none';
 
_.setLogLevel = function(level) {
  logLevel = level;
}
 
_.debug = function(msg) {
  if (logLevel === 'debug') {
    process.stdout.write('\n' + chalk.gray('[DEBUG]') + ' ' + msg + '\n');
  }
}
 
_.notice = function(msg) {
  process.stdout.write('\n' + chalk.cyan('[INFO]') + ' ' + msg + '\n');
}
 
_.warn = function(msg) {
  process.stdout.write('\n' + chalk.yellow('[WARNI]') + ' ' + msg + '\n');
}
 
_.error = function(msg) {
  process.stdout.write('\n' + chalk.red('[ERROR]') + ' ' + msg + '\n');
}
 
_.startBuilding = function(cmlType) {
  if (cmlType) {
    _.notice(`${cmlType} Compiling....`)
  } else {
    _.notice('start Compiling...')
  }
}