UNPKG

@bridgera-iot/bridgera-structured-logger

Version:

A lightweight structured logger for Node.js with JSON output to console and file, supporting custom transports.

12 lines (10 loc) 271 B
const Logger = require("./index"); const logger = new Logger("user-service"); try { throw new Error("Cannot read property 'id' of undefined"); } catch (error) { logger.error("Error occured - ", { errorMessage: error.message, stackTrace: error.stack, }); }