Getting cloudWatch is a legacy winston transport. Consider upgrading
surya-purohit opened this issue · 1 comments
surya-purohit commented
I was working on v2.3.0
and everything was perfectly fine. But when I update winston-cloudwatch
to v2.3.2. It started breaking and I saw a warning message displayed saying cloudWatch is a legacy winston transport. Consider upgrading
.
After degrading to 2.3.0
, it;s working again.
Code snippet:
import moment from 'moment';
import winston from 'winston';
import WinstonCloudWatch from 'winston-cloudwatch';
/**
* Function to push logs to cloudwatch
* @param {String} options.region Region of cloudwatch
* @param {String} options.secretAccessKey Secret Access Key of the AWS user
* @param {String} options.accessKeyId Access Key Id of the AWS user
* @param {String} options.logGroupName Log Group Name on which the log is to be written
* @param {Object} options Options to log to cloudwatch
* @return {Object} Logger Object
*/
export default function cloudwatchLog({
region: awsRegion,
secretAccessKey: awsSecretKey,
accessKeyId: awsAccessKeyId,
logGroupName,
}) {
const logger = winston.createLogger({
transports: [new WinstonCloudWatch({
awsRegion,
awsSecretKey,
awsAccessKeyId,
logGroupName,
logStreamName: `${moment.utc().format('MM-DD-YYYY')}`,
level: 'verbose',
jsonMessage: true,
})],
});
return logger;
}
In the other file I am importing this file and writing something like
const logger = require('./logger');
this.logger = logger(AWSConfig);
this.logger.info('I am done');
Once the logger is initialized, the warning is seen and while login like above, it gives error saying Callback is not a function
lazywithclass commented
Thanks for this, I am currently working on a 3.0 version for winston-cloudwatch.
I suggest upgrading once it's done and then seeing if this issue is still valid.