all files / lib/helpers/ Logger.js

89.36% Statements 42/47
85% Branches 17/20
100% Functions 12/12
58.33% Lines 7/12
10 statements, 6 functions, 8 branches Ignored     
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 39 40 41 42 43 44 45 46 47 48 49 50                                                                                       
import colors from 'colors';
 
const APP = 'postcss-cyspriter'.toUpperCase();
 
class Logger {
 
  static info(message) {
    console.log(colors.green(APP), message);
  }
 
  static generated(sprite) {
    let selector = colors.blue.underline(sprite.selector);
    const log =
      console.log
        .bind(console, colors.green(APP), `Sprite ${selector} generated.`);
 
    Eif(!sprite.debug) {
      log();
      return;
    }
 
    log('\n', {
      dir: sprite._inputDir,
      output: sprite.output,
      date: sprite.getTime(),
      cacheId: sprite.cacheBuster,
      images: sprite.length
    })
  }
 
  static fatal(error) {
    console.log(
      colors.red(`${APP}:ERROR`),
      colors.bold(error.name || ''),
      '\n',
      error,
      '\n',
      error.stack
    )
  }
 
  static warn() {
    let logs = Array.prototype.slice.call(arguments);
 
    console.log(colors.yellow(`${APP}:WARNING`), ...logs);
  }
}
 
export default Logger;