Sha256: ba2cb9182212d225eec7012f8d092811d42eb2896378c84b4937b96c9b53ccce

Contents?: true

Size: 925 Bytes

Versions: 4

Compression:

Stored size: 925 Bytes

Contents

import {indexOf} from './utils';

let logger = {
  methodMap: ['debug', 'info', 'warn', 'error'],
  level: 'info',

  // Maps a given level value to the `methodMap` indexes above.
  lookupLevel: function(level) {
    if (typeof level === 'string') {
      let levelMap = indexOf(logger.methodMap, level.toLowerCase());
      if (levelMap >= 0) {
        level = levelMap;
      } else {
        level = parseInt(level, 10);
      }
    }

    return level;
  },

  // Can be overridden in the host environment
  log: function(level, ...message) {
    level = logger.lookupLevel(level);

    if (typeof console !== 'undefined' && logger.lookupLevel(logger.level) <= level) {
      let method = logger.methodMap[level];
      if (!console[method]) {   // eslint-disable-line no-console
        method = 'log';
      }
      console[method](...message);    // eslint-disable-line no-console
    }
  }
};

export default logger;

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
locomotivecms-3.4.0 app/javascript/node_modules/handlebars/lib/handlebars/logger.js
lanes-0.8.0 node_modules/handlebars/lib/handlebars/logger.js
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/handlebars/lib/handlebars/logger.js
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/handlebars/lib/handlebars/logger.js