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

pino-postgres

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-postgres - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

38

index.js

@@ -11,2 +11,5 @@ #! /usr/bin/env node

let buffer = []
let interval
class PinoTransform extends Transform {

@@ -20,3 +23,3 @@ constructor (opts, sql) {

_transform (chunk, encoding, callback) {
const { schema, table, column, passThrough } = this.opts
const { column, passThrough } = this.opts
const content = chunk.toString('utf-8')

@@ -30,11 +33,4 @@ let log = {}

this.sql`
INSERT INTO ${this.sql(schema)}.${this.sql(table)} (${this.sql(column)}) VALUES (${this.sql.json(log)})
ON CONFLICT DO NOTHING;
`
.then(() => callback(null, passThrough ? `${chunk}\n` : null))
.catch((err) => {
console.error('error in pino-postgres transform', err)
callback(null, passThrough ? `${chunk}\n` : null)
})
buffer.push({ [column]: log })
callback(null, passThrough ? `${chunk}\n` : null)
}

@@ -79,3 +75,23 @@ }

const transport = new PinoTransform(opts, sql)
transport.on('end', sql.end)
transport.on('end', () => {
sql.end()
clearInterval(interval)
})
interval = setInterval(() => {
if (opts.debug) {
console.log(`DEBUG - buffer size: ${buffer.length}`)
}
if (buffer.length) {
this.sql`
INSERT INTO ${this.sql(opts.schema)}.${this.sql(opts.table)} (${this.sql(opts.column)}) VALUES (${this.sql(buffer)})
ON CONFLICT DO NOTHING;
`.catch((err) => {
console.error('error in pino-postgres sql', err)
})
buffer = []
}
}, 5000)
interval.unref()
pipeline(process.stdin, split(), transport, process.stdout, err => {

@@ -82,0 +98,0 @@ if (err) {

{
"name": "pino-postgres",
"version": "0.0.10",
"version": "0.0.11",
"description": "Pino transport for Postgres",

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

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