How to use the bunyan.nameFromLevel function in bunyan

To help you get started, we’ve selected a few bunyan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sensebox / openSenseMap-API / packages / api / lib / log.js View on Github external
const ip = obj.req.headers['x-forwarded-for'] ||
     obj.req.remoteAddress;

    return console.log(`[${obj.time.toISOString()} - ${ip}]: ${obj.req.method} ${obj.req.url}`);
  }

  if (obj.level >= bunyan.WARN) {
    if (obj.err) {
      return console.log(`[${obj.time.toISOString()} - ${bunyan.nameFromLevel[obj.level].toUpperCase()}]: ${obj.err.name} ${obj.src.file}:${obj.src.line}
  ${obj.err.message}
  ${obj.err.stack}
  ${obj.msg}
 `);
    }

    return console.log(`[${obj.time.toISOString()} - ${bunyan.nameFromLevel[obj.level].toUpperCase()}]: ${obj.msg} in ${obj.src.file}:${obj.src.line}`);
  }

  console.log(`[${obj.time.toISOString()} - ${bunyan.nameFromLevel[obj.level].toUpperCase()}]: ${obj.msg}`);
  /* eslint-enable no-console */
};
github wework / we-js-logger / src / util / client / consoleLogger.js View on Github external
} else if (data.level < bunyan.INFO) {
    levelCss = 'color: GoldenRod';
  } else if (data.level < bunyan.WARN) {
    levelCss = 'color: DarkTurquoise';
  } else if (data.level < bunyan.ERROR) {
    levelCss = 'color: Purple';
  } else if (data.level < bunyan.FATAL) {
    levelCss = 'color: Crimson';
  } else {
    levelCss = 'color: Black';
  }

  console.log( // eslint-disable-line no-console
    '[%s] %c%s%c: %s: %c%s',
    data.time,
    levelCss, bunyan.nameFromLevel[data.level],
    defaultCss, loggerName,
    msgCss, data.msg
  );

  if (data.err && data.err.stack) {
    console.error(data.err.stack); // eslint-disable-line no-console
  }
};
github RethinkRobotics-opensource / rosnodejs / src / lib / Logging.js View on Github external
const rootLoggerOptions = {
      name: DEFAULT_LOGGER_NAME,
      streams: [{
        type: 'raw',
        name: 'ConsoleLogStream',
        stream: new ConsoleLogStream({formatter: LogFormatter}),
        level: 'info'
      }],
      level: 'info'
    };
    this.rootLogger = new Logger(rootLoggerOptions);

    this._bindNodeLoggerMethods(this.rootLogger);
    this._cleanLoggersInterval = null;

    this.nameFromLevel = bunyan.nameFromLevel;
    this.levelFromName = bunyan.levelFromName;
    this.DEFAULT_LOGGER_NAME = DEFAULT_LOGGER_NAME;

    // in case the node we're running has it's own logging system, we'll
    // allow users to pass in callbacks for getting and setting loggers
    // through the logging services (_handleGetLoggers, _handleSetLoggerLevel)
    this._externalLog = {
      getLoggers: null,
      setLoggerLevel: null
    };

    KNOWN_LOGS.forEach((log) => {
      this.generateLogger(log);
    });
  }
github RethinkRobotics-opensource / rosnodejs / src / utils / log / RosLogStream.js View on Github external
_getRosLogLevel(bunyanLogLevel) {
    // ROS log levels defined in rosgraph_msgs/Log
    // bunyan trace and debug levels will both map to ROS debug
    if (bunyanLogLevel === bunyan.TRACE) {
      return RosgraphLogMsg.Constants.DEBUG;
    }
    // else
    return RosgraphLogMsg.Constants[bunyan.nameFromLevel[bunyanLogLevel].toUpperCase()];
  }
github numenta / numenta-apps / unicorn / app / config / logger.js View on Github external
write(rec) {
        let name = bunyan.nameFromLevel[rec.level];
        let method = (name === 'debug') ? 'log' : name;
        console[method]('[%s]: %s', name, rec.msg); // eslint-disable-line
      }
    },
github RethinkRobotics-opensource / rosnodejs / src / utils / log / LogFormatter.js View on Github external
format(rec) {
    return bunyan.nameFromLevel[rec.level].toUpperCase();
  }
}
github pact-foundation / pact-node / src / logger.js View on Github external
get: function () {
            return bunyan.nameFromLevel[this.level()];
        },
        enumerable: true,
github pact-foundation / pact-js / src / common / logger.ts View on Github external
public get logLevelName(): string {
    return bunyan.nameFromLevel[this.level()];
  }
}
github wework / we-js-logger / src / util / client / logentriesLogger.js View on Github external
ClientLogentriesLogger.prototype.write = function (data = {}) {
  const level = bunyan.nameFromLevel[data.level];
  if (isFunction(LE[level])) {
    LE[level](data);
  } else {
    LE.log(data);
  }
};
github RethinkRobotics-opensource / rosnodejs / src / lib / Logging.js View on Github external
this._forEachLogger((logger) => {
      resp.loggers.push({
        name: logger.getName(),
        level: bunyan.nameFromLevel[logger.getLevel()]
      });
    }, true);