How to use the cf-nodejs-logging-support.logMessage function in cf-nodejs-logging-support

To help you get started, we’ve selected a few cf-nodejs-logging-support examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-restify.js View on Github external
// parse body json params
app.use(restify.plugins.bodyParser({ mapParams: true }));

// setup CF port
var port = Number(process.env.VCAP_APP_PORT || 8080);
app.listen(port, function () {
    //write a message using the logMessage method of the logger.
    log.logMessage("info", "listening on port: %d", port);
});


// create a json object and send it as custom log with the given logger.
var stats = {};
stats.node_version = process.version;
log.logMessage("info", "Runtime statistics", stats);

// handling post messages
app.post("/post_message", function (req, res, next) {
    var msg = {
        "name": req.body.name,
        "time": req.body.time,
        "message": req.body.message,
        "timestamp": (new Date()).getTime()
    };

    req.logger.info(`received message from '${msg.name}': ${msg.message}`);

    if (redisRunning) {
        pub.publish("message", JSON.stringify(msg));
    } else {
        pushLocal(msg);
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-express.js View on Github external
// inserts the logger in the server network queue, so each time a https request is recieved, it is will get logged.
app.use(log.logNetwork);

app.use("/", express.static(__dirname + "/public"));

// setup CF port
var port = Number(process.env.VCAP_APP_PORT || 8080);
app.listen(port, function () {
    //write a message using the logMessage method of the logger.
    log.logMessage("info", "listening on port: %d", port);
});

// create a json object and send it as custom log with the given logger.
var stats = {};
stats.node_version = process.version;
log.logMessage("info", "Runtime statistics", stats);

// handling post messages
app.post("/post_message", function (req, res) {
    var msg = {
        "name": req.body.name,
        "time": req.body.time,
        "message": req.body.message,
        "timestamp": (new Date()).getTime()
    };

    req.logger.info(`received message from '${msg.name}': ${msg.message}`);

    if (redisRunning) {
        pub.publish("message", JSON.stringify(msg));
    } else {
        pushLocal(msg);
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-restify.js View on Github external
function redisEndHandler(err) {
    if (redisRunning) {
        log.logMessage("info", "redis disconnected!");
    }
    redisRunning = false;
}
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-restify.js View on Github external
function synchronize() {
    if (syncPointer != -1) {
        log.logMessage("verbose", "redis synchronization!");
        var syncMessage = {};
        syncMessage.data = messages.splice(syncPointer, messages.length - syncPointer);
        setTimeout(function () {
            pub.publish("message", JSON.stringify(syncMessage));
        }, 200);
        syncPointer = -1;
    }
}
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-restify.js View on Github external
function redisErrorHandler(err) {
    if (redisRunning) {
        log.logMessage("error", "redis error occured!");
    }
    redisRunning = false;
}
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-restify.js View on Github external
function synchronize() {
    if (syncPointer != -1) {
        log.logMessage("verbose", "redis synchronization!");
        var syncMessage = {};
        syncMessage.data = messages.splice(syncPointer, messages.length - syncPointer);
        setTimeout(function () {
            pub.publish("message", JSON.stringify(syncMessage));
        }, 200);
        syncPointer = -1;
    }
}
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-restify.js View on Github external
app.listen(port, function () {
    //write a message using the logMessage method of the logger.
    log.logMessage("info", "listening on port: %d", port);
});
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-express.js View on Github external
function synchronize() {
    if (syncPointer != -1) {
        log.logMessage("verbose", "redis synchronization!");
        var syncMessage = {};
        syncMessage.data = messages.splice(syncPointer, messages.length - syncPointer);
        setTimeout(function () {
            pub.publish("message", JSON.stringify(syncMessage));
        }, 200);
        syncPointer = -1;
    }
}
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-express.js View on Github external
function redisEndHandler() {
    if (redisRunning) {
        log.logMessage("info", "redis disconnected!");
    }
    redisRunning = false;
}
github SAP / cf-nodejs-logging-support / sample / cf-nodejs-shoutboard / web-express.js View on Github external
function redisConnectionHandler() {
    if (!redisRunning) {
        log.logMessage("info", "redis connected!");
    }
    redisRunning = true;
    sub.subscribe("message", "sync");
    synchronize();
}