Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
This library is a wrapper of winston logging library that adds additional beheaviour dedicated for our use.
var logger = require('cf-logs');
logger.info("info message");
logger.error("error message");
Notice that if you use this option then you will not be able to use the DEBUG environment variable to filter these logs.
So our main use should be with the advanced usage.
You can provide a namespace for your current logger, just like in 'debug' module and then controll the output logs with DEBUG environment variable
var logger = require('cf-logs').Logger("codefresh:example");
logger.info("info message");
logger.debug("debug meesage"):
This is very powerfull for development, because many times you want to see only logs from a specific part of the application so you can for example set the DEBUG environment variable to for example: "codefresh:builds".
The default is set so that all logs that begins with a namespace 'codefresh,codefresh:*' will be shown.
var logger = require('cf-logs').Logger("codefresh:example");
var error = new Error("very bad error");
logger.error("error: %s", error.toString());
logger.error("stack: %s", error.stack);
The options that can be passed are:
var options = {
filePath: String,
console: Boolean,
loggly:{
subdomain: String,
inputToken: String
},
showNamespace: Boolean,
env_module: String,
showRequestId: Boolean,
level: String(one of: "error/warn/info/debug"),
consoleOptions: {
formatter: function(options) {
// Receives the consoleOptions object, merged with the meta objects
// Should return a formatted string for this log.
// This is an example:
return new Date().toISOString() +' '+ options.level.toUpperCase() +' >> '+ (undefined !== options.message ? options.message : '') +
(options.meta && Object.keys(options.meta).length ? ' << ' + JSON.stringify(options.meta) : '' );
}
},
basePath: String,
baseNamepsace: String
}
var logger = require('cf-logs');
logger.setGlobalOptions(options);
Set 'filePath' field to an absolute path to a file save the logs to a file. The default is set to null which means no logging to file will happen.
Set 'console' filed to true or false to log to the console. The default is set to true
The logging level is an additional filter that can be set, mainly for production usage.
we have 4 levels, from highest to lowest priority:
Set 'showNamespace' field to true or false to show the namespace in the logs The default is false
You can set 'env_module' field to a name that will be shown on all logs. for example: "cf-api-machine-1" The default is set to null which will not print anything
Set 'showRequestId' field to true or false to show the current request id if exists The default is set to false
Set the basePath to your project root (__dirname), then create loggers with __filename as the namespace. Also, set your base namespace. (e.g. lalala) Result: basePath: /home/user/workspace/projectDir namespace: projectName newLogger(//home/user/workspace/projectDir/internalDir/file.js) will get the namespace: projectName:internalDir:file
FAQs
codefresh logs
The npm package cf-logs receives a total of 375 weekly downloads. As such, cf-logs popularity was classified as not popular.
We found that cf-logs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.