wx-logmonitor

0.1.7 • Public • Published

wx-logmonitor

NPM

Installation

npm install wx-logmonitor --save

Configuration:

First create a start script (e.g. index.js) and include the module:

var wxlogmonitor = require('wx-logmonitor');

Add some general configuration (e.g. send mail):

var sendMail = wxlogmonitor.buildSendmail( {
        from: 'sysadmin',
        to: 'admin@meinedomaine.homeserver.local',
        smtpConfig: {
            host: 'localhost'
        }
    }
)

Create file monitors to watch new lines

var isLogMon = wxlogmonitor.create("C:/SoftwareAG/IntegrationServer/instances/default/logs/server.log", {
    logPattern: "IS",
    id: "IS_default"
});
 
var mwsLogMon = wxlogmonitor.create("C:/SoftwareAG/MWS/server/default/logs/_full_.log", {
    logPattern: "MWS",
    id: "MWS_default"
});
 
var isWrapperLogMon = wxlogmonitor.create("C:/SoftwareAG/profiles/IS_default/logs/wrapper.log", {
    logPattern: "WRAPPER",
    id: "IS-OSGI_default"
});
 
var mwsWrapperLogMon = wxlogmonitor.create("C:/SoftwareAG/profiles/MWS_default/logs/wrapper.log", {
    logPattern: "WRAPPER",
    id: "MWS-OSGI_default"
});
 
/* 
even more ...
*/

Add rules for error messages, log messages and (unexpected) errors

/**
 * handle error message (level is ERROR or severe)
 */
isLogMon.onErrorMsg( (logMsg) => {
    console.log('Error in msg %s', logMsg.msg);
})
 
isLogMon.onErrorMsg( (logMsg) => {
   if (logMsg.level === 'Critical') {
       console.log('ACTION2: It\'s really getting critical. Please react immediately on #%s! ', logMsg.code);
   }
})
 
isLogMon.onErrorMsg( (logMsg) => {
   if (! /^ISS.0015/.test(logMsg.code)) {
        sendMail({
            subject: 'IS Error',
            text: 'An error occurred in IS log file: \n' + logMsg.getFullMsg()
        });
   } else {
       console.log('Only ISS.0015, just ignore!');
   }
})
 
/*
even more ...
 */
 
/**
 * handle log messages
 */
isLogMon.onLogMsg( function(logMsg) {
    if (/ISP.0090/.test(logMsg.code) && /Just LogMsg/.test(logMsg.msg) ) {
        setTimeout( function() {
            console.log("### catch my messsage (%s: %s), doing some tests after 1 sec...", logMsg.no, logMsg.msg);
        }, 1000);
    };
});
 
/*
even more ...
 */
 
isLogMon.onError( function(error) {
    console.log('unexpected error occured: ', error);
});

After configuration start wx-logmonitor:

/**
 * start Log Monitoring ... 
 */
wxlogmonitor.start();

Usage

To start log monitor you open a command line and invoke node.js

node . start 

License

MIT. Please see License file for more details.

Readme

Keywords

none

Package Sidebar

Install

npm i wx-logmonitor

Weekly Downloads

15

Version

0.1.7

License

none

Last publish

Collaborators

  • markog