A Mysql transport for winston. This module is writted by sapher and mantained by me.
$ npm install winston
$ npm install winston-mysql-transport
(or add it to your package.json)
First you must generate your log table
/*file : extras/schema.sql*/
CREATE TABLE IF NOT EXISTS `my_database`.`log_table` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`level` varchar(45) NOT NULL,
`message` text NOT NULL,
`timestamp` datetime NOT NULL,
`meta` varchar(255),
`hostname` varchar(255),
PRIMARY KEY (`id`)
);
And in your code...
var winston = require('winston');
//
// Requiring `winston-mysql-transport` will expose
// `winston.transports.Mysql`
//
require('winston-mysql-transport').Mysql;
options = {
database : "my_database",
table : "log_table",
user : "root"
}
winston.add(winston.transports.Mysql, options);
You can find a list of options that you can pass here :
https://github.com/beinnova/winston-mysql-transport.git#connection-options
This transport does not support (yet) :
- streaming
- querying
#CHANGELOG 1.1
Now you can save metadata. You can pass a object or string.