emails for rental cancelation, rental declined, rental request confirmation, payout received
This commit is contained in:
@@ -25,15 +25,43 @@ const level = () => {
|
||||
return isDevelopment ? 'debug' : process.env.LOG_LEVEL || 'info';
|
||||
};
|
||||
|
||||
// Custom format to extract stack traces from Error objects in metadata
|
||||
const extractErrorStack = winston.format((info) => {
|
||||
// Check if any metadata value is an Error object and extract its stack
|
||||
Object.keys(info).forEach(key => {
|
||||
if (info[key] instanceof Error) {
|
||||
info[key] = {
|
||||
message: info[key].message,
|
||||
stack: info[key].stack,
|
||||
name: info[key].name
|
||||
};
|
||||
}
|
||||
});
|
||||
return info;
|
||||
});
|
||||
|
||||
// Define log format
|
||||
const logFormat = winston.format.combine(
|
||||
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }),
|
||||
winston.format.colorize({ all: true }),
|
||||
extractErrorStack(),
|
||||
winston.format.printf((info) => {
|
||||
if (info.stack) {
|
||||
return `${info.timestamp} ${info.level}: ${info.message}\n${info.stack}`;
|
||||
const { timestamp, level, message, stack, ...metadata } = info;
|
||||
let output = `${timestamp} ${level}: ${message}`;
|
||||
|
||||
// Check for stack trace in the info object itself
|
||||
if (stack) {
|
||||
output += `\n${stack}`;
|
||||
}
|
||||
return `${info.timestamp} ${info.level}: ${info.message}`;
|
||||
|
||||
// Check for Error objects in metadata
|
||||
Object.keys(metadata).forEach(key => {
|
||||
if (metadata[key] && metadata[key].stack) {
|
||||
output += `\n${key}: ${metadata[key].message}\n${metadata[key].stack}`;
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -41,6 +69,7 @@ const logFormat = winston.format.combine(
|
||||
const jsonFormat = winston.format.combine(
|
||||
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }),
|
||||
winston.format.errors({ stack: true }),
|
||||
extractErrorStack(),
|
||||
winston.format.json()
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user