Skip to content
New issue

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

Does not work with Lambda #228

Open
adamleemiller opened this issue Mar 26, 2024 · 1 comment
Open

Does not work with Lambda #228

adamleemiller opened this issue Mar 26, 2024 · 1 comment

Comments

@adamleemiller
Copy link

I am looking for a way to send my Winston generated logs to CloudWatch and found this module / plugin / project and had high hopes but after about two hours, I am not able to get it to work with Lambda. The code does work locally and the log stream does get created and logged to however when deploying via Lambda, the log stream is not created.

Here is the current code I am using:

const cloudwatchLogger = logger.add(new WinstonCloudWatch({
  awsOptions: {
    credentials: {
      accessKeyId: process.env.AWS_ACCESSKEYID,
      secretAccessKey: process.env.AWS_SECRETACCESSKEYID
    },
    region: process.env.CLOUDWATCH_REGION
  },
  name: 'cloudwatchLogger',
  logGroupName: process.env.CLOUDWATCH_GROUP_NAME,
  logStreamName: `${process.env.CLOUDWATCH_GROUP_NAME}-${process.env.NODE_ENV}`,
  awsRegion: process.env.CLOUDWATCH_REGION
}))

cloudwatchLogger.transports.find((t) => t.name === 'cloudwatchLogger').kthxbye(() => {
  console.log('---===...transport buffer flushed...===---')
})

It would also be great to be able to define the log formatter using the built-in Winston combine method. For example, this is what I use in my other transports:

      format: winston.format.combine(
        winston.format.errors({ stack: false }),
        winston.format.timestamp({
          format: 'MMM-DD-YYYY HH:mm:ss'
        }),
        winston.format.metadata(),
        winston.format.prettyPrint(),
        winston.format.json()
      )

Lastly, it does not appear that this project is maintained anymore. There are multiple open issues, some with fixes, but no response from the project maintainer. Is this project still supported?

@lazywithclass
Copy link
Owner

Hi @adamleemiller, I am not actively maintaining the project anymore.

winston-cloudwatch definitely supported AWS Lambda in the past as I wrote a function specifically for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants