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

bunyan

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunyan - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

16

CHANGES.md

@@ -9,2 +9,18 @@ # bunyan Changelog

## bunyan 1.2.4
- [issue #210] Export `bunyan.nameFromLevel` and `bunyan.levelFromName`. It can
be a pain for custom streams to have to reproduce that.
- [issue #100] Gracefully handle the case of an unbound
`Logger.{info,debug,...}` being used for logging, e.g.:
myEmittingThing.on('data', log.info)
Before this change, bunyan would throw. Now it emits a warning to stderr
*once*, and then silently ignores those log attempts, e.g.:
bunyan usage error: /Users/trentm/tm/node-bunyan/foo.js:12: attempt to log with an unbound log method: `this` is: { _events: { data: [Function] } }
## bunyan 1.2.3

@@ -11,0 +27,0 @@

63

lib/bunyan.js

@@ -11,3 +11,3 @@ /**

var VERSION = '1.2.3';
var VERSION = '1.2.4';

@@ -58,8 +58,12 @@ // Bunyan log format version. This becomes the 'v' field on all log records.

/**
* A shallow copy of an object. Bunyan logging attempts to never cause
* exceptions, so this function attempts to handle non-objects gracefully.
*/
function objCopy(obj) {
if (obj === null) {
return null;
if (obj == null) { // null or undefined
return obj;
} else if (Array.isArray(obj)) {
return obj.slice();
} else {
} else if (typeof (obj) === 'object') {
var copy = {};

@@ -70,2 +74,4 @@ Object.keys(obj).forEach(function (k) {

return copy;
} else {
return obj;
}

@@ -147,18 +153,18 @@ }

* @param msg {String} Message with which to warn.
* @param file {String} Optional. File path relevant for the warning.
* @param line {String} Optional. Line number in `file` path relevant for
* the warning.
* @param dedupKey {String} Optional. A short string key for this warning to
* have its warning only printed once.
*/
function _warn(msg, file, line) {
function _warn(msg, dedupKey) {
assert.ok(msg);
var key;
if (file && line) {
key = file + ':' + line;
if (_warned[key]) {
if (dedupKey) {
if (_warned[dedupKey]) {
return;
}
_warned[key] = true;
_warned[dedupKey] = true;
}
process.stderr.write(msg + '\n');
}
function _haveWarned(dedupKey) {
return _warned[dedupKey];
}
var _warned = {};

@@ -198,2 +204,6 @@

};
var nameFromLevel = {};
Object.keys(levelFromName).forEach(function (name) {
nameFromLevel[levelFromName[name]] = name;
});

@@ -764,6 +774,5 @@ // Dtrace probes.

} catch (err) {
_warn(format('bunyan: ERROR: This should never happen. '
+ 'This is a bug in <https://github.com/trentm/node-bunyan> '
+ 'or in this application. Exception from "%s" Logger '
+ 'serializer: %s',
_warn(format('bunyan: ERROR: Exception thrown from the "%s" '
+ 'Bunyan serializer. This should never happen. This is a bug'
+ 'in that serializer function.\n%s',
name, err.stack || err));

@@ -891,3 +900,19 @@ fields[name] = format('(Error in Bunyan log "%s" serializer '

var rec = null;
if (arguments.length === 0) { // `log.<level>()`
if (! this._emit) {
/*
* Show this invalid Bunyan usage warning *once*.
*
* See <https://github.com/trentm/node-bunyan/issues/100> for
* an example of how this can happen.
*/
var dedupKey = 'unbound';
if (!_haveWarned[dedupKey]) {
var caller = getCaller3Info();
_warn(format('bunyan usage error: %s:%s: attempt to log '
+ 'with an unbound log method: `this` is: %s',
caller.file, caller.line, util.inspect(this)),
dedupKey);
}
return;
} else if (arguments.length === 0) { // `log.<level>()`
return (this._level <= minLevel);

@@ -1351,2 +1376,4 @@ } else if (this._level > minLevel) {

module.exports.resolveLevel = resolveLevel;
module.exports.levelFromName = levelFromName;
module.exports.nameFromLevel = nameFromLevel;

@@ -1353,0 +1380,0 @@ module.exports.VERSION = VERSION;

{
"name": "bunyan",
"version": "1.2.3",
"version": "1.2.4",
"description": "a JSON logging library for node.js services",

@@ -5,0 +5,0 @@ "author": "Trent Mick <trentm@gmail.com> (http://trentm.com)",

@@ -998,13 +998,10 @@ Bunyan is **a simple and fast JSON logging library** for node.js services:

```javascript
var bunyan = require('./lib/bunyan');
function MyRawStream() {}
MyRawStream.prototype.write = function (rec) {
var nameFromLevel = {
TRACE: 'TRACE'
DEBUG: 'DEBUG',
INFO: 'INFO',
WARN: 'WARN',
ERROR: 'ERROR',
FATAL: 'FATAL'
};
console.log('[%s] %s: %s', rec.time, nameFromLevel[rec.level], rec.msg);
console.log('[%s] %s: %s',
rec.time.toISOString(),
bunyan.nameFromLevel[rec.level],
rec.msg);
}

@@ -1019,3 +1016,3 @@

type: 'raw'
},
}
]

@@ -1022,0 +1019,0 @@ });

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