Socket
Socket
Sign inDemoInstall

egg-logger

Package Overview
Dependencies
Maintainers
5
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-logger - npm Package Compare versions

Comparing version 1.7.0 to 1.7.1

6

History.md
1.7.1 / 2018-07-09
==================
**fixes**
* [[`b80560b`](http://github.com/eggjs/egg-logger/commit/b80560b1906ff667db24345029ac8951622ebe59)] - fix: use circular-json to format error properties (#26) (Yiyu He <<dead_horse@qq.com>>)
1.7.0 / 2018-06-21

@@ -3,0 +9,0 @@ ==================

36

lib/utils.js

@@ -9,2 +9,3 @@ 'use strict';

const levels = require('./level');
const circularJSON = require('circular-json');

@@ -158,3 +159,36 @@ const hostname = os.hostname();

function inspect(key, value) {
return `${key}: ${util.inspect(value, { breakLength: Infinity })}`;
return `${key}: ${formatObject(value)}`;
}
function formatString(str) {
if (str.length > 10000) {
return `${str.substr(0, 10000)}...(${str.length})`;
}
return str;
}
function formatBuffer(buf) {
const tail = buf.data.length > 50 ? ` ...(${buf.data.length}) ` : '';
const bufStr = buf.data.slice(0, 50).map(i => {
i = i.toString(16);
if (i.length === 1) i = `0${i}`;
return i;
}).join(' ');
return `<Buffer ${bufStr}${tail}>`;
}
function formatObject(obj) {
try {
return circularJSON.stringify(obj, (key, v) => {
if (typeof v === 'string') return formatString(v);
if (v && v.type === 'Buffer' && Array.isArray(v.data)) {
return formatBuffer(v);
}
if (v instanceof RegExp) return util.inspect(v);
return v;
});
} catch (_) {
/* istanbul ignore next */
return String(obj);
}
}

3

package.json
{
"name": "egg-logger",
"version": "1.7.0",
"version": "1.7.1",
"description": "egg logger",

@@ -8,2 +8,3 @@ "main": "index.js",

"chalk": "^1.1.3",
"circular-json": "^0.5.4",
"debug": "^2.6.2",

@@ -10,0 +11,0 @@ "depd": "^1.1.0",

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