Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-bunyan

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-bunyan - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

34

lib/index.js

@@ -20,2 +20,4 @@ 'use strict';

function logEvent(ctx, data, request) {
if (!data) return;
var obj = {};

@@ -30,13 +32,16 @@ var msg = '';

if (typeof data.data === 'string') {
if (data instanceof Error) {
ctx.log.child(obj)[ctx.level](data);
return;
}
var type = typeof data.data;
if (type === 'string') {
msg = data.data;
} else if (ctx.includeData && data.data !== undefined) {
if (ctx.mergeData) {
try {
lodash.assign(obj, data.data);
if (ctx.mergeData && type === 'object' && !Array.isArray(data.data)) {
lodash.assign(obj, data.data);
if (obj.id === obj.req_id) delete obj.id;
} catch (err) {
obj.data = data.data;
}
if (obj.id === obj.req_id) delete obj.id;
} else {

@@ -74,5 +79,3 @@ obj.data = data.data;

var makeCtx = function(tags, defaultLevel) {
var level;
var makeCtx = function(tags, level) {
if (tags.fatal) {

@@ -90,4 +93,2 @@ level = 'fatal';

level = 'trace';
} else {
level = defaultLevel || 'debug';
}

@@ -154,11 +155,11 @@

server.on('request-error', function(request, data) {
server.on('request-error', function(request, err) {
var tags = {};
var ctx = makeCtx(tags, 'error');
if (handler.call(ctx, 'request-error', request, data, tags)) {
if (handler.call(ctx, 'request-error', request, err, tags)) {
return;
}
logEvent(ctx, data, request);
logEvent(ctx, err, request);
});

@@ -182,2 +183,3 @@

exports.log = logEvent;
exports.register = register;
{
"name": "hapi-bunyan",
"version": "0.5.1",
"version": "0.6.0",
"main": "./lib",

@@ -11,9 +11,10 @@ "description": "Simple Bunyan logging in Hapi",

"bunyan": "^1.0.0",
"code": "^1.3.0",
"hapi": "^8.0.0",
"jscs": "^1.5.9",
"jshint": "^2.5.3",
"lab": "^4.0.2"
"lab": "^5.2.1"
},
"scripts": {
"test": "./node_modules/.bin/jshint lib test && ./node_modules/.bin/jscs lib test && ./node_modules/.bin/lab -c"
"test": "./node_modules/.bin/jshint lib test && ./node_modules/.bin/jscs lib test && ./node_modules/.bin/lab -c -t 100"
},

@@ -20,0 +21,0 @@ "repository": {

@@ -1,2 +0,2 @@

# Hapi Bunyan
# Hapi Bunyan [![Build Status](https://travis-ci.org/silas/hapi-bunyan.png?branch=master)](https://travis-ci.org/silas/hapi-bunyan)

@@ -3,0 +3,0 @@ This a simple [Bunyan][bunyan] plugin for Hapi.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc