npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bunyan-mssql-stream

v0.1.3

Published

bunyan ms sql logging stream

Readme

Bunyan MS SQL Stream

Bunyan MSSQL Stream provides a logging stream direct to a MS SQL table.

Minimum required fields in your table are

  • time (DateTime, will log in UTC)
  • name (string)
  • hostname (string)
  • pid (int)
  • level (string)
  • levelID (int)
  • src (string, only required if you plan to enable src)

Any objects passed to the logger will be inserted into fields of the same name. All values converted to parameters to prevent injection.

Installation

npm install bunyan-mssql-stream

Sample Usage

var bunyan = require('bunyan');
var mssqlStream = require('bunyan-mssql-stream');

var log_config = {
    user: 'db username',
    password: 'db password',
    database: 'default database',
    table: 'log table name',
    server: 'db server host/ip',
    requestTimeout: 30000 // Milliseconds before timing out a query
};

var logger = bunyan.createLogger({
    name: 'logger name',
    streams: [
    {
        level: 'info',
        type: 'raw',
        stream: mssqlStream.createStream(log_config)
    }]
});

logger.info( { message: 'hello world', detail: "Additional details" } );

The above example will log all INFO messages to the SQL table defined in log_config.table. Along with the default fields, "hello world" will be inserted into a field named message, and "Additional Details" into a field named detail. Any fields used must already exist on your table. Do not use a field named msg!

If you pass in an object, it will be automatically stringified and written as JSON text. For example

logger.info( { message: {MyVar1: 'Value 1', MyVar2: 'Value 2'} } );

and

var myObject = {
    MyVar1: 'Value 1',
    MyVar2: 'Value 2'
};

logger.info({ message: myObject });

will both log the text { MyVar1: 'Value 1', MyVar2: 'Value 2' } to the message field.

Notes

  • SQL data types will be mapped per https://www.npmjs.com/package/mssql#input
    • If the destination field is of INT type, it is recommended to pass that value as Number(YourVariable) to ensure propper mapping
  • Log entries sent before the DB connection has been made are automatically queued and comitted after the connection is up.
  • Due to the asynchronous nature, records may not be inserted in the same order they were logged. However if sorted by the time field, they can be retrieved in correct chronological order.

Next Version

  • Allow omitting any "required" fields via config
  • Add a method for specifying type mapping via config