3.1.0 • Published 2 years ago

lambda-log v3.1.0

Weekly downloads
18,416
License
MIT
Repository
github
Last release
2 years ago

lambda-log

npm npm GitHub Workflow Status Code Climate coverage license Code Climate maintainability CodeFactor Grade Snyk Vulnerabilities for npm package

All Contributors

CAUTION!

This branch and release (@next) is under heavy development. This exists for testing and anyone who is willing to help out with testing. DO NOT USE IN PRODUCTION!

If you do decide to try out this brand new version of LambdaLog, please report any issues you face as I can only catch so much. Any help would be greatly appreciated, especially if you are more versed in TypeScript than I am!

What's new?

This is the next major release of LambdaLog (v4.0.0) which contains many major breaking changes, new features, and TypeScript support.

Breaking Changes

  • Complete rewrite of most of the core functionality into TypeScript.
  • Custom Log Levels has been removed.
  • Log levels are now hardcoded and cannot be changed. This greatly simplifies the code and allows us to support TypeScript.
  • Use of Symbol has been removed along with any static properties on the classes to retrieve the symbols.
  • The debug option has been removed.
  • The default key name for levelKey has changed from _logLevel to __level.
  • The default key name for tagsKey has changed from _tags to __tags.
  • The shortcut log methods are now hardcoded instead of dynamically generated.
  • Removed addLevel() method from LambdaLog class.
  • Removed isError() and stubError() static methods from the LogMessage class and moved them into utility functions.
  • Environment variables that configure different options now take precedence over locally configured options.
  • Internally used properties on the LogMessage class have been renamed.

New Features

  • You can now configure the verbosity of your log messages through the new level option or LAMBDALOG_LEVEL env variable.
  • Added fatal and trace log levels.
  • Added onParse option that allows for custom parsing of log messages.
  • Added onCompile option that allows for custom structuring of the object that is logged to the console.
  • Added onFormat option that allows for custom formatting of the logged message. This gives the ability to render log messages in any format, not just JSON. (#75)
    • Added clean formatter that logs a message in a readable format.
    • Added minimal formatter that logs a message in a readable format without tags and metadata.
    • Ability to provide your own custom formatter as a function.
  • Added ability to configure the level, dev, and silent options via environment variables.
  • Full written in TypeScript with complete type definitions. (#63, #64)
  • The package now provides an ESM and CommonJS version to support your project.

Fixes

  • Fixed issue where directly setting log.options.logHandler did not work (#45).

Misc. Changes

  • Rewrote most tests into TypeScript and still maintaining 100% coverage.

What's left?

It has been a pretty large undertaking for me, but one that this package desperately needed. This was my first real dive into TypeScript, so I'm sure there are things than can be written better. If there is anyone with more advanced TypeScript knowledge, I'm in great need of someone who can review the code and suggest any changes or help refactor the code to get this production-ready. (I'll even add you as a maintainer!)

  • Testing package implementation in Node for both vanilla JavaScript and TypeScript.
  • Testing ESM support with Node and ensuring CommonJS works correctly as well.
  • Ensuring the end-user has access to all the proper files and functionality.
  • Documentation.

Release Date

As much as I am trying to rush this out the door to get these features in the hands of all you awesome developers/engineers, I'm also limited on time (eg. I'm currently writing this documentation at midnight knowing that I have to wake up at 5:30am). Not only that, but I want to ensure I ship this next version of LambdaLog with performance, features, and stability in mind. I hope this will be the last major version for awhile.

Enough with all of that cheesy sob-story, let's talk about when this will be released, well, what I'm aiming for at this point. I hope to finish up most of my to-do list in the next couple of weeks and try to solicit some outside help for testing/analysis. Once that is complete, I hope to get this released as the latest stable version towards the end of 2021 or at the beginning of 2022. That's not guarantee at this point, but it will definitely be feasible if anyone in the community can help out!


LambdaLog is a Node.js package facilitates and enforces logging standards in Node.js processes or applications anywhere by formatting your log messages as JSON for simple parsing and filtering within log management tools, such as CloudWatch Logs. Works with all of the supported versions of Node.js on Lambda.

Originally created for AWS Lambda Functions, LambdaLog is a lightweight and feature-rich library that has no dependency on AWS or Lambda, meaning you can use it in any type of Node.js project you wish. It's really a universal JSON logger.

Why another lambda logger? There are plenty of other logging libraries in the NPM ecosystem but most are convoluted, included more functionality than needed, not maintained, or are not configurable enough. I created LambdaLog to include the important functionality from other loggers, but still maintaining simplicity with minimal dependencies.

Features

Anyone can log JSON to the console, but with Lambda Log you also get:

  • Metadata and tags that may be set globally or individually for each log message.
  • Error and Error-like objects logged include stacktraces in the metadata automatically.
  • Each log message emits an event to allow third-party integration.
  • Pluggable and customizable by extending the LambdaLog class.
  • Pretty-printing of the JSON log message in dev mode.
  • Well documented, commented, and maintained source code.
  • Over 1.5 million downloads and more than 35k weekly downloads.
  • Small footprint.

Documentation

Documentation for Lambda Log has moved to our new website.

Note: The documentation has NOT been updated for this new release yet. I'm working on it!

Tests

See Development Documentation.

Contributing

See Contributing Documentation.

License

MIT License. See License in the repository.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!