1.0.1 • Published 5 years ago
forge-nodejs-logs v1.0.1
forge-nodejs-logs
Installation:
npm install forge-nodejs-logs --save
Usage:
import {ForgeLogger} from "forge-nodejs-logs";
const logger = new ForgeLogger({
mongoUrl: "mongodb://localhost:27017/forge-logs", // optional
appInsightKey: "your-instrumentation-key", // optional
console: true,
filename: "somefile.log", // optional
level: "debug",
role: "my-microservice",
roleId: "my-microservice-1"
});
for (let i = 0; i < 100; i++) {
logger.debug("A debug");
logger.info("An info", { anything: "This is metadata" });
logger.warn("A warning");
logger.error("A terrible error");
}
const loggerContext = logger.enrich({myEnrichedData: "test"});
loggerContext.info("Another info");
setTimeout(() => logger.close(), 10000);
Also a IForgeLogger
, ForgeLoggerContext
and NullForgeLogger
classes are exported.