Git Product home page Git Product logo

pino-pg's Introduction

DISCONTINUED

pino-pg

A Pino Transport for PostgreSQL databases.

GitHub Workflow Status GitHub npm

Requirement

This package requires at least Node.js version 10.

Installation

npm install pino-pg

Usage

Store logs to PostgreSQL.

node my-app.js | pino-pg --connectionUrl <your connection string> --table <your logs table> --column <your column table>

Options

  • The connectionUrl (or u) must contain the postgres url string.
  • The table (or t) must contain the table name. Default to logs.
  • The column (or c) must contain the name of the JSONB column where you want to store log entries.

License

Licensed under MIT

pino-pg's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar holmok avatar xstoudi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pino-pg's Issues

"Error: Cannot find module './args'" error when first use

implemented this way

nodemon index.js | pino-pg --connectionUrl postgresql://xxx:xxx@xxx:5432/holmok --table holmok_me.logs --column log | pino-tiny,

I installed the latest version an I am getting the following error:

Error: Cannot find module './args'
Require stack:
- /Users/christopher.holmok/work/holmok.me/node_modules/pino-pg/dist/src/index.js
- /Users/christopher.holmok/work/holmok.me/node_modules/pino-pg/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/christopher.holmok/work/holmok.me/node_modules/pino-pg/dist/src/index.js:9:32)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/christopher.holmok/work/holmok.me/node_modules/pino-pg/dist/src/index.js',
    '/Users/christopher.holmok/work/holmok.me/node_modules/pino-pg/index.js'
  ]
}

stream.on is not a function

Hello,
I'm facing a problem using pino-pg
On my package.json, scripts area I have the following:

"dev": "nodemon --exec babel-node ./api/index.js | pino-pg --connectionUrl postgresql://xxxxxx:[email protected]:5432/dbname --table pinologs --column log",

But when running on console the command "npm run dev" the following appears:

internal/streams/pipeline.js:27
  stream.on('close', () => {
         ^

TypeError: stream.on is not a function
    at destroyer (internal/streams/pipeline.js:27:10)
    at internal/streams/pipeline.js:79:12
    at Array.map (<anonymous>)
    at Function.pipeline (internal/streams/pipeline.js:76:28)
    at client.connect (D:\Work\Project\node_modules\pino-pg\dist\src\index.js:57:18)
    at Connection.<anonymous> (D:\Work\Project\node_modules\pino-pg\node_modules\pg\lib\client.js:253:7)
    at Object.onceWrapper (events.js:273:13)
    at Connection.emit (events.js:187:15)
    at parse (D:\Work\Project\node_modules\pino-pg\node_modules\pg\lib\connection.js:109:10)
    at Parser.parse (D:\Work\Project\node_modules\pino-pg\node_modules\pg-protocol\dist\parser.js:40:17)

SyntaxError: Unexpected token in JSON at position 0

I am getting this while using it with esm package

$ nodemon -r esm -e yaml,js,json index | pino-pg --connectionUrl postgres://xxx:[email protected]:5432/easycollab --table test.logs --column log

SyntaxError: Unexpected token  in JSON at position 0
    at JSON.parse (<anonymous>)
    at /Users/shivam/real-dev/easy-collab-api/node_modules/pino-pg/dist/src/index.js:36:100
    at Generator.next (<anonymous>)
    at resume (/Users/shivam/real-dev/easy-collab-api/node_modules/pino-pg/dist/src/index.js:15:44)
    at fulfill (/Users/shivam/real-dev/easy-collab-api/node_modules/pino-pg/dist/src/index.js:17:31)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)

Do not create a new connection for each chunk.

Currently the code creates a new connection for each chunk.

This approach is going to fail under high throughput.
I would recommend

  1. reuse the connection
  2. batch a series of inserts into a single bulk operation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.