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

@binxhealth/pino-stackdriver

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

@binxhealth/pino-stackdriver - npm Package Compare versions

Comparing version 1.1.0 to 3.0.0

.github/workflows/ci.yml

36

index.js

@@ -1,23 +0,5 @@

#!/usr/bin/env node
const split = require('split2')
const parseJson = require('fast-json-parse')
const fastJson = require('fast-json-stringify')
const pumpify = require('pumpify')
const stringifyJson = fastJson({
type: 'object',
properties: {
time: { type: 'string' },
hostname: { type: 'string' },
level: { type: 'integer' },
msg: { type: 'string' },
pid: { type: 'integer' },
req: { type: 'object', additionalProperties: true },
res: { type: 'object', additionalProperties: true },
responseTime: { type: 'integer' },
v: { type: 'integer' },
severity: { type: 'string' }
}
})
function pinoStackdriver (line) {

@@ -29,9 +11,11 @@ const { value } = parseJson(line)

case 20: value.severity = 'DEBUG'; break
case 30: value.severity = 'INFO'; break
case 40: value.severity = 'WARNING'; break
case 50: value.severity = 'ERROR'; break
case 60: value.severity = 'CRITICAL'; break
default: value.severity = 'INFO'
}
value.time = new Date(value.time).toISOString()
line = stringifyJson(value)
if (value.time) {
value.time = new Date(value.time).toISOString()
}
line = JSON.stringify(value)
}

@@ -41,2 +25,8 @@ return line + '\n'

process.stdin.pipe(split(pinoStackdriver)).pipe(process.stdout)
const transform = split(pinoStackdriver)
function createStream () {
return pumpify(transform, process.stdout)
}
module.exports = { transform, createStream }
{
"name": "@binxhealth/pino-stackdriver",
"version": "1.1.0",
"version": "3.0.0",
"description": "A utility that makes express-pino logs StackDriver-compatible",
"main": "index.js",
"bin": {
"pino-stackdriver": "index.js"
"pino-stackdriver": "cli.js"
},

@@ -30,10 +30,11 @@ "scripts": {

"fast-json-parse": "^1.0.3",
"fast-json-stringify": "^1.15.3",
"pumpify": "^2.0.1",
"split2": "^3.1.1"
},
"devDependencies": {
"@ianwalter/bff": "^5.2.1",
"@ianwalter/eslint-config": "^2.0.1",
"execa": "^1.0.0",
"np": "^5.0.3"
"@ianwalter/bff": "^7.0.0",
"@ianwalter/eslint-config": "^3.1.0",
"@ianwalter/release": "^3.0.6",
"@ianwalter/renovate-config": "^1.2.0",
"execa": "^3.3.0"
},

@@ -45,3 +46,13 @@ "eslintConfig": {

]
},
"renovate": {
"extends": [
"@ianwalter"
]
},
"release": {
"registries": [
"github"
]
}
}

@@ -1,8 +0,10 @@

# pino-stackdriver
# @binxhealth/pino-stackdriver
> A utility that makes express-[pino][pinoUrl] logs StackDriver-compatible
[![CI][ciImage]][ciUrl]
## Installation
```console
npm install @binxhealth/pino-stackdriver --save
yarn add @binxhealth/pino-stackdriver --dev
```

@@ -22,3 +24,20 @@

Or create a new stream and pass it to [pino][pinoUrl]
```javascript
import { createStream } from '@binxhealth/pino-stackdriver';
const logger = pino(
{
level: 'debug',
},
createStream()
);
logger.info('This works the same as usual...');
logger.error('...and will log to stdout with the correct Stackdriver format');
```
[pinoUrl]: http://getpino.io/#/
[ciImage]: https://github.com/binxhealth/pino-stackdriver/workflows/CI/badge.svg
[ciUrl]: https://github.com/binxhealth/pino-stackdriver/actions

@@ -6,3 +6,3 @@ const { join } = require('path')

const pinoStackdriver = join(__dirname, '../')
const pinoStackdriver = join(__dirname, '../cli')
const lineOne = JSON.stringify({

@@ -30,2 +30,3 @@ time: 1544043395681,

}) + '\n'
const lineThree = "{ Error => `Lalala-la lalal-la Elmo's world!` }"

@@ -35,17 +36,24 @@ test('pino-stackdriver adds severity to log entry', ({ expect }) => {

const stdin = new Readable({ read () {} })
const cp = execa('node', [pinoStackdriver])
let counter = 0
const cp = execa('node', [pinoStackdriver], { reject: false })
let lines = []
cp.stdout.on('data', data => {
expect(JSON.parse(data)).toMatchSnapshot()
if (counter) {
resolve()
} else {
counter++
}
const rawLines = data.toString().split('\n')
lines = lines.concat(rawLines.filter(line => line))
})
cp.stdout.on('close', () => {
expect(lines).toMatchSnapshot()
resolve()
})
// Write logs to stream.
stdin.pipe(cp.stdin)
stdin.push(lineOne)
stdin.push(lineTwo)
stdin.push(null) // Push null to close the stream.
stdin.push(lineThree)
// Push null to close the streams.
stdin.push(null)
cp.stdin.push(null)
})
})

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