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

bunyan-sql-stream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunyan-sql-stream

Stream your Bunyan logs to your favorite SQL database

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22
decreased by-46.34%
Maintainers
1
Weekly downloads
 
Created
Source

bunyan-sql-stream

Build Status NPM Version Coverage

This package creates a Bunyan stream that can write to a number of different SQL databases.

Currently, it supports:

  • PostgreSQL
  • MSSQL
  • MySQL
  • MariaDB
  • SQLite3
  • Oracle

The stream maps the default Bunyan log fields to table columns and also stores the entire log message. Depending on your database's capabilities, it will attempt to store the message in a json, jsonb, or text column type.

Installation

npm install --save bunyan-sql-stream

Usage

First, create the table you want to store your logs in:

create table if not exists "public"."logs" (
  "id" serial primary key,
  "name" text,
  "level" integer,
  "hostname" text,
  "msg" text,
  "pid" integer,
  "time" timestamptz,
  "content" jsonb
)

Then, use the package as a Bunyan stream:

const logger = bunyan.createLogger({
  name: 'sql stream',
  level: 'info',
  stream: bunyanSqlStream({
    client: 'pg',
    connection: {
      host: 'localhost',
      user: 'postgres',
      password: 'password',
      database: 'db'
    },
    tableName: 'logs'
  })
})

This package uses the same client and connection options as Knex.js.

Database Clients

You'll also need to install a database client for each type of database you'll be logging to.

For example, if you're using PostgreSQL:

npm install --save pg

The package should issue an error message that will tell you which module to install once you set the client option.

Additional Info

This package depends on Knex.js. If want to minimize dependencies, you might prefer another module:

Contributing

Pull requests welcome.

License

MIT © Forrest Desjardins

Keywords

FAQs

Package last updated on 01 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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