Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
cf-nodejs-logging-support
Advanced tools
Add the following dependency to your package.json.
"dependencies": {
"cf-nodejs-logging-support": "git+https://github.com/SAP/cf-nodejs-logging-support"
}
var express = require('express');
var log = require('cf-nodejs-logging-support');
var app = express();
// Set the minimum logging level (Levels: error, warn, info, verbose, debug, silly)
log.setLoggingLevel("info");
// Bind to express app
app.use(log.logNetwork);
app.get('/', function (req, res) {
// Context bound custom message
req.logMessage("info", "Hello World will be send");
res.send('Hello World');
});
app.listen(3000);
// Formatted log message free of request context
log.logMessage("info", "Server is listening on port %d", 3000);
Use the logMessage(...) function to log custom messages with a given logging level. It is also possible to use the standard format placeholders equivalent to the util.format method.
Custom messages may be called on two objects:
Simple message
logMessage("info", "Hello World");
// ... "msg":"Hello World" ...
With addtional numeric value
logMessage("info", "Listening on port %d", 5000);
// ... "msg":"Listening on port 5000" ...
With additional string values
logMessage("info", "This %s a %s", "is", "test");
// ... "msg":"This is a test" ...
With custom fields added to custom_fields field. Keep in mind, that the last argument is handled as custom fields object, if it is an object.
logMessage("info", "Test data %j", {"field" :"value"});
// ... "msg":"Test data %j"
// ... "custom_fields": {"field": "value"} ...
With json object forced to be embedded in to the message (nothing will be added to custom_fields).
logMessage("info", "Test data %j", {"field" :"value"}, {});
// ... "msg":"Test data {\"field\": \"value\"}" ...
This logging tool can be used in conjunction with Winston. Example:
var express = require('express');
var log = require('cf-nodejs-logging-support');
var winston = require('winston');
var app = express();
var logger = new(winston.Logger)({
// Bind transport to winston
transports: [log.winstonTransport]
});
app.get('/', function (req, res) {
res.send('Hello World');
});
app.listen(3000);
// Messages will now be logged exactly as demonstrated by the Custom Messages paragraph
logger.log("info", "Server is listening on port %d", 3000);
FAQs
Logging tool for Cloud Foundry
The npm package cf-nodejs-logging-support receives a total of 50,118 weekly downloads. As such, cf-nodejs-logging-support popularity was classified as popular.
We found that cf-nodejs-logging-support demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.