New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bunlogger

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunlogger - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

26

lib/logger.js

@@ -60,7 +60,31 @@ 'use strict';

var customized = {
err: serialErr,
// modified from bunyan for express
req: function (req) {
if (!req || !req.connection)
return req;
return {
method: req.method,
url: req.originalUrl || req.url,
headers: req.headers,
remoteAddress: req.connection.remoteAddress,
remotePort: req.connection.remotePort
};
// Trailers: Skipping for speed. If you need trailers in your app, then
// make a custom serializer.
//if (Object.keys(trailers).length > 0) {
// obj.trailers = req.trailers;
//}
}
};
var serializers = Object.assign(bunyan.stdSerializers, customized);
return bunyan.createLogger({
name,
streams,
serializers: Object.assign(bunyan.stdSerializers, {err: serialErr})
serializers
});
};

10

lib/serialErr.js

@@ -26,3 +26,4 @@ 'use strict';

if (!err || !err.stack)
return err;
return Object.assign({}, err);
var obj = {

@@ -52,4 +53,9 @@ message: err.message,

let original = stringify(err.original);
let original = null;
try {
original = stringify(err.original);
} catch (er) {}
try {
obj.original = JSON.parse(original);

@@ -56,0 +62,0 @@ } catch (er) {

{
"name": "bunlogger",
"description": "bunyan logger, bunyan express middleware, pretty print err for development",
"version": "3.0.3",
"version": "3.0.4",
"author": "Ben P.P. Tung",

@@ -6,0 +6,0 @@ "bugs": {

@@ -14,5 +14,5 @@ bunlogger

========
1. `app.use(logger.connect())` will populate the `req.log`, which is actually a child of the bunyan logger, simply `req.log.info('...')` will share the same `cor_id` in the `access log` and `error log`.
1. `app.use(logger.connect())` will populate the `req.log`, which is actually a child of the bunyan logger, simply `req.log.info('...')` will share the same `cor_id` in the `access log` and `error log`. cor_id is exposed on `req.cor_id`;
2. logging `req.log.fatal()`, `req.log.error()`, `req.log.warn()` into error log file. If error is sent to `next(err)` and `req.log[error_level]` not got called, middleware `app.use(logger.onError())` will log this error by `error.status` automatically. err.status == 4xx is warn level, err.status == 5xx is error level.
2. logging `req.log.fatal()`, `req.log.error()` into error log file. If error is sent to `next(err)` and `req.log['fatal|error']` not got called, middleware `app.use(logger.onError())` will log this error by `error.status` automatically. err.status == 4xx is warn level, err.status == 5xx is error level.

@@ -25,2 +25,3 @@ 3. `elapsed` show the time spent in this `req`.

Quick Start

@@ -54,2 +55,4 @@ ==========

Finally, render `req.cor_id` in the final error handler, so the customer can contact you with `cor_id` for help.
### Create logger

@@ -73,2 +76,4 @@

A handy tool to replace console.error(err).
```

@@ -75,0 +80,0 @@ const printErr = require('bunlogger').printErr;

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