Giter VIP home page Giter VIP logo

bunyan-mysql2's Introduction

bunyan-mysql2

A Bunyan stream for saving logs into Mysql.

Install

npm install bunyan-mysql2

Create Table

Create table in your host

CREATE TABLE log(
	name varchar(200),
	hostname varchar(200),
	msg varchar(21845),
	pid integer,
	level integer,
	time datetime,
	v integer
);

Example

var bunyan      = require('bunyan');
var MySqlStream = require('bunyan-mysql2');

var msqlStream = new MySqlStream({
    host     : 'localhost',
    user     : 'user',
    password : 'pass',
    database : 'database',
    port     : 3306
});

msqlStream.on('error', function (err) {
    console.log('MySQL Stream Error:', err.stack);
});

var log = bunyan.createLogger({
    name: "My Application",
    streams: [
        { stream: process.stdout },
        { stream: msqlStream }
    ],
    serializers: bunyan.stdSerializers
});

log.info('Oh My God, this works!!!');

Options

  • host: The hostname of the database you are connecting to. (Default: localhost)
  • user: The MySQL user to authenticate as.
  • password: The password of that MySQL user.
  • database: Name of the database to use for this connection (Optional).
  • port: The port number to connect to. (Default: 3306)
  • table: Name of table log. (Default: log)
  • connectionLimit: The maximum number of connections to create at once. (Default: 10)

Credits

Package developed based on bunyan-mysql package.

bunyan-mysql2's People

Contributors

williamcc89 avatar

Watchers

 avatar

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.