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

ackee-node-logger

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ackee-node-logger - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

stackdriver.js

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## [0.2.5] - 2018-09-10
### Added
- log object are automatically enhanced for Google Stackdriver
- `options.disableStackdriverFormat` to prevent logger from modifying log objects
## [0.2.4] - 2018-09-06

@@ -2,0 +8,0 @@

@@ -7,2 +7,3 @@ const _ = require('lodash');

const { expressMiddleware, expressErrorMiddleware } = require('./express');
const { StackDriverFormatStream } = require('./stackdriver');

@@ -72,2 +73,13 @@ // This is a custom slightly edited version of pino-multistream's wirte method, whch adds support for maximum log level

}
if (!_.get(options, 'disableStackdriverFormat', false)) {
streams = streams.map(stream => {
const newStream = new StackDriverFormatStream();
newStream.pipe(stream.stream);
return {
level: stream.level,
maxLevel: stream.maxLevel,
stream: newStream,
};
});
}

@@ -74,0 +86,0 @@ if (!options.ignoredHttpMethods) {

2

package.json
{
"name": "ackee-node-logger",
"version": "0.2.4",
"version": "0.2.5",
"description": "Ackee Node Logger",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -103,2 +103,3 @@ # Simple pino-based logger setup for Ackee purposes

- `pretty` - if set to `true`, logger will use [pino pretty human-readable logs](https://github.com/pinojs/pino/blob/master/docs/API.md#pretty). This option can be overriden by `streams`
- `disableStackdriverFormat` - if set to `true`, logger will add `severity` field to all log objects, so that log levels in Google Stackdriver work as expected
- `config` - object, which will be passed to underlying logger object. Right now, underlying logger is [pino](https://github.com/pinojs/pino), so for available options see [pino API docs](https://github.com/pinojs/pino/blob/master/docs/API.md#pinooptions-stream)

@@ -105,0 +106,0 @@

@@ -144,1 +144,44 @@ const express = require('express');

});
test('severity field is automatically added to log object', () => {
const loggerWrites = jest.fn();
const logger = loggerFactory({
streams: [
{
stream: new stream.Writable({
write: (chunk, encoding, next) => {
const json = JSON.parse(chunk);
expect(json.severity).toBe('CRITICAL');
loggerWrites();
next();
},
}),
},
],
});
logger.fatal('Hello');
expect(loggerWrites).toBeCalled();
});
test('automatic severity field can be disabled by options', () => {
const loggerWrites = jest.fn();
const logger = loggerFactory({
disableStackdriverFormat: true,
streams: [
{
stream: new stream.Writable({
write: (chunk, encoding, next) => {
const json = JSON.parse(chunk);
expect(json.severity).toBe(undefined);
loggerWrites();
next();
},
}),
},
],
});
logger.fatal('Hello');
expect(loggerWrites).toBeCalled();
});
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