Skip to content

fix: Add ability to log objects easily#140

Merged
dipasqualew merged 1 commit intomasterfrom
log-objects
Jan 21, 2021
Merged

fix: Add ability to log objects easily#140
dipasqualew merged 1 commit intomasterfrom
log-objects

Conversation

@dipasqualew
Copy link
Copy Markdown
Contributor

Sometimes we want to log an object, i.e. "Processing: X", but there is a
lot of boilerplate involved each time, as we need to JSON.stringify the
object and put the result in a template string.

The .object method will cut the boilerplate for us.

Sometimes we want to log an object, i.e. "Processing: X", but there is a
lot of boilerplate involved each time, as we need to JSON.stringify the
object and put the result in a template string.

The `.object` method will cut the boilerplate for us.
Copy link
Copy Markdown
Contributor

@seb-cr seb-cr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine.

This has reminded me though, in general, I'd prefer to be able to use Logger.info (or warning or error) in the same way as console.log: passing an arbitrary number of arguments and it stringifies and logs all of them. Then your example would become simply Logger.info('Processing', X). Most loggers I've used work like that and it's a bit confusing that LambdaWrapper's works differently. I guess this would be a breaking change; something to consider for v2 maybe?

@dipasqualew
Copy link
Copy Markdown
Contributor Author

Yeah I think it would be a breaking change for how .error works at the moment. When we migrate to TypeScript we will update how logger works!

@dipasqualew dipasqualew merged commit c3f5efc into master Jan 21, 2021
@dipasqualew dipasqualew deleted the log-objects branch January 21, 2021 12:53
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.4.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants