Registry / database / winston-postgres

winston-postgres

JSON →
library0.0.4jsnpmunverified

A Winston transport for logging messages to a PostgreSQL database. Version 0.0.4 – appears to be a mature but unmaintained package with limited releases. It supports both table-based logging (specifying a table with columns 'level', 'message', 'metadata') and PostgreSQL function-based logging. Key options include connection string, SSL toggle, timestamp, table name, database function, and an optional ignoreMessage filter. Requires Winston (version 0.x compatibility noted) and a running PostgreSQL instance. Differentiating from other transports: it uses connection string directly and supports custom database functions.

npm install winston-postgres
INSTALL
IMPORT
SIG · WINSTON-POSTGRES
W
winston-postgres
databasejavascriptv0.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Postgres
import { Postgres } from 'winston-postgres';
import Postgres from 'winston-postgres';
Named export. CJS: const Postgres = require('winston-postgres').Postgres;
winston.transports.Postgres
import winston from 'winston'; import { Postgres } from 'winston-postgres'; winston.add(new winston.transports.Postgres(options));
const winston = require('winston'); winston.add(winston.transports.Postgres);
Add transport as instance: winston.add(new winston.transports.Postgres(...)).
Postgres constructor options
new (require('winston-postgres').Postgres)({ connectionString: '...', tableName: 'logs' })
new require('winston-postgres').Postgres({})
Options object must include either tableName or databaseFunction.

Adds Postgres transport to winston using a connection string and table name, with SSL disabled and message filtering.

import winston from 'winston'; import { Postgres } from 'winston-postgres'; winston.add(new Postgres({ ssl: false, timestamp: true, connectionString: process.env.DB_URL ?? 'postgres://admin:admin@localhost:5432/api', tableName: 'winston-logs', ignoreMessage: (level, message, metadata) => message === 'ignore_this' })); winston.info('Hello, world!');
Debug
Known issues
gotchaMissing tableName or databaseFunction: transport will not log and may silently fail
fix
Provide either `tableName` or `databaseFunction` option.
affects: *
gotchaSSL default behavior: SSL is disabled by default (ssl: false) – not secure for production
fix
Set `ssl: true` and ensure proper certificates in production.
affects: *
breakingCommonJS require: const Postgres = require('winston-postgres'); is incorrect – missing .Postgres
fix
Use const Postgres = require('winston-postgres').Postgres; or destructure.
affects: *
gotchaData type mismatch: column 'metadata' must be JSON/text – transport assumes column exists
fix
Ensure table has columns: level (text), message (text), metadata (jsonb or text).
affects: *
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'Postgres')
Using require('winston-postgres') without accessing the named export
fix
const Postgres = require('winston-postgres').Postgres;
Error: getaddrinfo ENOTFOUND localhost
PostgreSQL server not running or incorrect host in connectionString
fix
Start PostgreSQL server or update connectionString to correct host/port.
error: relation "winston-logs" does not exist
Specified table name does not exist in database
fix
Create table: CREATE TABLE winston-logs (level TEXT, message TEXT, metadata JSONB);
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
winstonrequiredpeer dependency – this is a winston transport
pgrequiredPostgreSQL client driver
Agent activity
19 hits · last 30 days
node
14
Meta
2
OpenAI (training)
1
Resources
winston-postgres — npm install winston-postgres · libregistry