KyleRoss / node-lambda-log

Basic logging mechanism for Node.js Lambda Functions and other AWS services, which produces logs in JSON format for easier reading through Cloudwatch Logs.
https://lambdalog.dev
MIT License
193 stars 16 forks source link

feat: set loglevel #62

Closed obiwabrakenobi closed 1 year ago

obiwabrakenobi commented 3 years ago

Type of Change

New Feature to set a specific loglevel and do not log anything below that level. It also incoorperates with custom loglevels. I did not change the documentation yet since I'm awaiting your feedback on the PR. For me it is reasonable and also works nicely with custom level. So no big change. As this repo is mainly used for aws lambda setting fine granular loglevels can save lots of cloudwatch costs.

Description of Change(s)

Changed the Levels like:

this[symbols.LEVELS] = {
  off: ['log', 200],
  error: ['error', 300],
  warn: ['warn', 400],
  info: ['info', 500],
  debug: ['debug', 600],
  ...levels
};

to enable a classic loglevel setting. I removed the debug option and added the level more implicit. This works with custom level too.

Checklist

KyleRoss commented 3 years ago

Awesome work on this! I'm currently in the process of building version 4.0.0 of LambdaLog now to solve this issue along with a few others that have been on my backlog. In order to solve one of the other issues (typescript types), I will need to remove the custom log levels anyway.

I think this change is too big right now and should be a major version release (ex. v4.0.0) because it contains breaking changes for a feature that is widely used by others at this time. I also do not want to release back-to-back major version releases that would end up forcing people to change their code twice.

I'm going to leave this open for right now and integrate a portion of this PR into my current build. If I'm not able to get this build shipped within the next few weeks, I will merge this PR :)

Thanks again for this! I will keep you updated!

obiwabrakenobi commented 3 years ago

Sounds great. Just ping me if you need me to write the documentation