How to use the bunyan.stdSerializers 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 joyent / moray / test / load / manta1027.js View on Github external
if (cluster.isMaster) {
        // Fork workers.
        for (var i = 0; i < numCPUs; i++) {
                cluster.fork();
        }

        cluster.on('exit', function (worker, code, signal) {
                console.log('worker ' + worker.process.pid + ' died');
        });
} else {
        var client = moray.createClient({
                log: bunyan.createLogger({
                        level: 'warn',
                        name: 'manta1027',
                        stream: process.stdout,
                        serializers: bunyan.stdSerializers
                }),
                url: process.env.MORAY_URL
        });

        client.once('connect', function () {
                function put() {
                        client.putObject('manta', '1027', {}, function (err) {
                                if (err) {
                                        console.error(err.stack);
                                }
                                put(i);
                        });
                }

                var max = parseInt(process.env.MANTA1027_CONCURRENCY || 20, 10);
                console.log('running...');
github ericelliott / bunyan-request-logger / lib / logger.js View on Github external
stack: getFullStack(err),
          code: err.code,
          signal: err.signal,
          requestId: err.requestId
      };    
    }
  },

  // Bunyan offers lots of other options,
  // including extensible output stream types.
  // 
  // You might be interested in
  // node-bunyan-syslog, in particular.
  defaults = {
    name: 'unnamed app',
    serializers: mixIn({}, bunyan.stdSerializers,
      serializers)
  },

  /**
   * Take bunyan options, monkey patch request
   * and response objects for better logging,
   * and return a logger instance.
   * 
   * @param  {Object} options See bunyan docs
   * @return {Object} logger  See bunyan docs
   * @return {Function} logger.requestLogger
   *                    (See below)
   */
  createLogger = function (options) {
    var settings = mixIn({}, defaults, options),
      log = bunyan.createLogger(settings);
github ericelliott / bunyan-request-logger / request-logger.js View on Github external
stack: getFullStack(err),
          code: err.code,
          signal: err.signal,
          requestId: err.requestId
      };
    }
  },

  // Bunyan offers lots of other options,
  // including extensible output stream types.
  //
  // You might be interested in
  // node-bunyan-syslog, in particular.
  defaults = {
    name: 'unnamed app',
    serializers: assign({}, bunyan.stdSerializers,
      serializers)
  },

  /**
   * Take bunyan options, monkey patch request
   * and response objects for better logging,
   * and return a logger instance.
   *
   * @param  {object}  options See bunyan docs
   * @param  {boolean} options.logParams
   *         Pass true to log request parameters
   *         in a separate log.info() call.
   * @return {object}  logger  See bunyan docs
   * @return {function} logger.requestLogger
   *                    (See below)
   */
github meetup / meetup-web-platform / packages / mwp-logger-plugin / src / logger.js View on Github external
* `{ seconds, nanos }`, where `nanos` is the nanosecond component of the
 * time
 *
 * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration
 */
const formatDuration = ms => {
	const seconds = Math.floor(ms / 1000); // whole seconds
	const nanos = (ms % 1000) * 1000 * 1000; // remainder milliseconds in nanoseconds (= ms * 1,000,000)
	return {
		seconds,
		nanos,
	};
};

const serializers = {
	...bunyan.stdSerializers,
};

/*
 * These serializers correspond to the 2 major types of 'request'/'response'
 * objects that are used in MWP apps - Hapi requests and http.IncomingMessage
 * responses that are returned from the `request` library for server-to-server
 * requests.
 */
export const httpRequestSerializers = {
	hapi: request => {
		const requestInfo = {
			requestMethod: request.method.toUpperCase(),
			requestUrl: request.url.href,
			requestSize: request.headers['content-length'],
			userAgent: request.headers['user-agent'],
			remoteIp: request.info.remoteAddress,
github Codigami / hapi-starter-kit / server / utils / logger.js View on Github external
const bunyan = require('bunyan')
const config = require('config')

// create a logger instance
const log = bunyan.createLogger({
  name: config.get('app.name'),
  level: config.get('app.logLevel'),
  serializers: bunyan.stdSerializers
})

module.exports = log
github joyent / manatee / lib / adm.js View on Github external
var prompt = require('prompt');
var restify = require('restify');
var sprintf = require('extsprintf').sprintf;
var jsprim = require('jsprim');
var util = require('util');
var vasync = require('vasync');
var VError = require('verror');
var ZfsClient = require('./zfsClient');
var zk = require('joyent-zookeeper-client');

var LOG = bunyan.createLogger({
    name: 'manatee-adm',
    level: (process.env.LOG_LEVEL || 'fatal'),
    src: true,
    serializers: {
        err: bunyan.stdSerializers.err
    }
});

exports.checkLock = checkLock;
exports.freeze = freeze;
exports.unfreeze = unfreeze;
exports.history = history;
exports.promote = promote;
exports.clearPromote = clearPromote;
exports.rebuild = rebuild;
exports.reap = reap;
exports.setOnwm = setOnwm;
exports.zkActive = zkActive;
exports.zkState = zkState;
exports.stateBackfill = stateBackfill;
exports.status = status;
github sean-stanley / FoodCoop / server / controllers / product.js View on Github external
var Product = require('./../models/product'),
Order = require('./../models/order'),
scheduler = require('./../scheduler'),
Emailer = require('./../emailer.js'),
async = require('async'),
bunyan = require('bunyan'),
log = bunyan.createLogger({
	name: 'product',
	serializers: {
		req: bunyan.stdSerializers.req,
		err: bunyan.stdSerializers.err,
		e: bunyan.stdSerializers.err,
		res: bunyan.stdSerializers.res,
		error: bunyan.stdSerializers.err
	}
}),
ObjectId = require('mongoose').Types.ObjectId,
_ = require('lodash');

exports.product = function(req, res, next, id) {
	Product.findById(id, function(err, product) {
		if (err) return next(err);
		req.product = product;
		next();
	});
};
github ryanfitz / elasticauth-api / example / index.js View on Github external
'use strict';

var Hapi       = require('hapi'),
    elasticApi = require('../index'),
    server     = new Hapi.Server(),
    vogels     = require('vogels'),
    AWS        = vogels.AWS,
    bunyan     = require('bunyan');

var opts = { endpoint : process.env.DYNAMODB_ENDPOINT, apiVersion: '2012-08-10' };
var dynamodb = new AWS.DynamoDB(opts);
vogels.dynamoDriver(dynamodb);

var log = bunyan.createLogger({
  name: 'example-server',
  serializers: bunyan.stdSerializers
});

server.connection({ port: 8080, host : 'localhost', address: '0.0.0.0' });

server.register( {
  register : elasticApi,
  options : {
    key : 'BbZijuoXAdr85UzyijKARZimKfrSmQ6fv8kZ7OFfc',
    facebookAppSecret : process.env.FACEBOOK_APP_SECRET,
    log : log,
    cognito : {
      identityPoolId : process.env.COGNITO_IDENTITY_POOL_ID,
      developerProviderName : process.env.COGNITO_DEVELOPER_PROVIDER_NAME
    },
    mailer : {
      fromAddress : 'login@example.com',