We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As a Developer, I should be able to create logs for errors, info, etc with a single line.
Here is some sample code I've written in the past using winston:
import winston from "winston"; const base = winston.createLogger({ level: "info", format: winston.format.printf(({ level, message, label, timestamp }) => { return `[LOGGER] ${level}: ${message}`; }), transports: [ new winston.transports.File({ filename: "./logs/error.log", level: "error", }), new winston.transports.File({ filename: "./logs/combined.log" }), ], }); if (process.env.NODE_ENV !== "production") { base.add( new winston.transports.Console({ format: winston.format.combine( winston.format.colorize(), winston.format.printf((info) => { const { level, message, label, timestamp } = info; const colorizer = winston.format.colorize().colorize; return `${colorizer("info", `[LOGGER]`)} ${level}: ${message}`; }), ), }), ); } interface log { message: string; body: string; } class Logger { private format = (log: log): string => { return `{message: "${log.message}", body: ${log.body}}`; }; public info(log: log): void { const formattedLog = this.format(log); base.info(formattedLog); } public error(log: log): void { const formattedLog = this.format(log); base.error(formattedLog); } public warn(log: log): void { const formattedLog = this.format(log); base.warn(formattedLog); } } const logger = new Logger(); export default logger;
Add this code or implement your own logger and update the console.log statements on src/jobs/dailyTaskReminder.ts to use the logger.
src/jobs/dailyTaskReminder.ts
Additionally, to any error blocks or try catch statements, add error log statements.
Here is a resource to read about structured logging and it's importance: https://stackify.com/what-is-structured-logging-and-why-developers-need-it/
The text was updated successfully, but these errors were encountered:
karimaljundi
No branches or pull requests
As a Developer, I should be able to create logs for errors, info, etc with a single line.
Here is some sample code I've written in the past using winston:
Add this code or implement your own logger and update the console.log statements on
src/jobs/dailyTaskReminder.ts
to use the logger.Additionally, to any error blocks or try catch statements, add error log statements.
Here is a resource to read about structured logging and it's importance: https://stackify.com/what-is-structured-logging-and-why-developers-need-it/
The text was updated successfully, but these errors were encountered: