rhodeslogger

1.0.3 • Public • Published

General file information

##--

Use this module for getting the request for logging the data from the main application.

It containing the database server call using the procedure containing the parameters to logged the log data into the database server.

It uses the some primary columns like logTime,logdescription ,logType etc.

Configuration file is maintain for connection to database and also for other future purpose.

feature/loggerModule

Configuration file information

-For database configuration need MSSQL which is mentioned in the config file.

var config = { sqlConfiguration: { user: '', password: '', server: '', database: '', } ##-- ##--

logConfiguration and logType is set in the config file.

-logConfiguration decide data to logged into the server or not on the basis of true and false.

-incase of error configuration does't matter, it will log.

logConfiguration: { isError: true, isInfo: true, isWarning: true, isDebug: true, isEvent: true }, logType: { error: "ERROR", info: "INFO", warning: "WARNING", debug: "DEBUG", event: "EVENT" } ##-- ##--

logger module implementation

-we can implement this module as a service or module

-service implementation

we have to create a server and deploy.

var restify = require('restify'), rhodeslogger = require("./index"), configuration = require(__dirname + "\config"), port = configuration.listeningPort, ip = configuration.listeningIP;

var server = restify.createServer({ name: "rhodeslogger" });

server.use(restify.queryParser()); server.use(restify.bodyParser()); server.use(restify.CORS());

this is code snippet for module implementation.

##-- rhodeslogger.isWriteLog("INFO",{welcome:'welcome'},function(data){ console.log(data) })

##--

below snippet for module implementation like web service

below method will log data without verifying config.logConfiguration property

server.post({path: '/logger', version: '0.0.1'}, function (req, res, well) { try { var bodyOfRequest = JSON.parse(req.body); //Checks the supplied value if null or empty. var logType = (bodyOfRequest.logType ? bodyOfRequest.logType : "ERROR"); var data = (bodyOfRequest.data ? JSON.stringify(bodyOfRequest.data) : "{}"); rhodeslogger.writeLog(logType, data); res.json({status: true}); } catch (err) { res.json({status: false, errorMessage: err.message}); } });

below method will log data based on config.logConfiguration property

server.post({path: '/isLogger', version: '0.0.1'}, function (req, res, well) { try { var bodyOfRequest = JSON.parse(req.body); //Checks the supplied value if null or empty. var logType = (bodyOfRequest.logType ? bodyOfRequest.logType : "ERROR"); var data = (bodyOfRequest.data ? JSON.stringify(bodyOfRequest.data) : "{}"); rhodeslogger.isWriteLog(logType, data); res.json({status: true}); } catch (err) { res.json({status: false, errorMessage: err.message}); } });

Package Sidebar

Install

npm i rhodeslogger

Weekly Downloads

1

Version

1.0.3

License

ISC

Last publish

Collaborators

  • kushalt