winstonjs-mail-transport
v1.1.1
Published
Mail transport for WinstonJS logger
Readme
Mail Transport
Mail transport for Winston It can send email to the given configuration when the log level matches the one you provide in the config
Usage
const mailTransport = new MailTransport({
transportOptions: {
level: 'error',
format: htmlFormat,
},
messageOptions: {
from: {
name: process.env.LOGGER_EMAIL_NAME as string,
address: process.env.LOGGER_EMAIL as string,
},
to: `[email protected]`,
},
config: {
host: process.env.LOGGER_MAIL_HOST,
port: parseInt(process.env.LOGGER_MAIL_PORT as string),
auth: {
user: process.env.LOGGER_MAIL_USERNAME,
pass: process.env.LOGGER_MAIL_PASSWORD,
},
},
});
const logger = createLogger({
format: format.combine(
format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss',
}),
format.errors({ stack: true }),
format.splat(),
),
transports: [mailTransport],
});