0.0.14 • Published 1 year ago
oute-services-logger-sdk v0.0.14
This module expose helper functions
- Initialization
var logger_instance = require("oute-services-logger-sdk")
Cache functions
Core functions
- Express middleware for initializing the logger id
app = express();
app.use(workspace_instance.expressLoggingMiddleware);
- Get logger instance
logger_config = {
level: "info", //any of [error, warn, info, http, verbose, debug, silly], this will be used to suppress the logs, dont send if want to log all
defaultMeta: {service: "my-service"}, //This will be appened in all the logs
transports: [new winston.transports.Console] //list of transport used for logging
format: myformat(), //This can be used to change the log formats, dont change untill you know,
log_locally: true //Using this we can control if we want to log locally or not
}
logger = workspace_instance.getLoggerInstance(logger_config);
- To log the request and response
app = express();
logger_config = {
logger: logger, //This is your logger instance,
excluded_urls: [{reg_exp : "/service/public", reg_option : "g"}], //This can be used to exclued the url from logging
}
app.use(workspace_instance.requestLogger(logger_config));