Logging module for node
The idea behind creating this module was to equip developers with the ability to log errors in a efficient yet simple manner. This module provides enough flexibility to log errors and warnings or even useful information as per required.
Also the need arised in the process of creating an API for the scoreboard web application (still under development).
As of now the following logging trasports are supported
MySQL database File Console
mysql - mysql driver for node
The node-log module can be used by creating a new instance of Logger.
var logn = ;var logger =debugLevel: 'error'consoleLog: true //whether to log messages to consolefileLog: true //whether to log messages to filefilename: 'appname.log' //location of the filemySQLLog: true //whether to log messages to MySQL database//mysql optionsmySQLOptions:host: 'host' //host for MySQL databaseuser: 'username'password: 'password'database: 'databasename'table: 'tablename';
Now you can use the
logger object to log the errors.
// using the generic log methodlogger;// using specific methods, ie. error(), warn() and info()logger;
A datetime stamp is automatically added while logging messages to MySQL and file.
Make sure that you destroy the connection to the MySQL database(not required if the
mySQLLog config option is set to false).
//ends the connection to the MySQL database, if one was madelogger;
Feel free to contribute pull requests.
Contact me at firstname.lastname@example.org or tweet me @kandoiabhi