question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] `format` should accept undefined as a valid value

See original GitHub issue

Describe the bug

I want to add a custom formatter, but only in production mode. What I tried is this:

format: process.env.environment !== `production` ? undefined : ctx => `...`,

This works in production mode, but not in any other mode, because undefined isn’t a function.

TypeError: config.format is not a function   
    at Object.exports.formatMessage (...\node_modules\better-logging\dist\lib\formatMessage.js:44:37)     
    at ...\node_modules\better-logging\dist\lib\decorateObject.js:21:58

I’m guessing this is due to the use of something like Object.entries(), which will yield the key format with value undefined if format is specified as such, instead of omitting it, like it does when it’s actually not defined.

Expected behavior

A simple error handling to check if the value of format (or any other option, for that matter) is undefined, and if it is, handle it the exact same way as if it we actually undefined 😃

Desktop (please complete the following information):

  • Windows 10, Node.js 14.15.1

Additional context

The package is great! 😄

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Olian04commented, Mar 23, 2021

Implemented in release 4.5.0

1reaction
Olian04commented, Mar 17, 2021

@Chaphasilor I think I’ve decided that I don’t have any strong opinions either way. So might as well go with your idea. I’ll have a look at a clean implementation soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request: An "undefined" value in addition to "null" #385
In my practice no one cares if value is not setted at all or it's just an unusable value. If field is required...
Read more >
PutItem - Amazon DynamoDB - AWS Documentation
Invalid Requests with empty values will be rejected with a ValidationException exception. ... The request accepts the following data in JSON format.
Read more >
7 Tips to Handle undefined in JavaScript - Dmitri Pavlutin
A detailed article about 'undefined' keyword in JavaScript. 7 tips on how to handle correctly 'undefined' and increase code durability.
Read more >
Places Library | Maps JavaScript API - Google Developers
To use the functionality contained within this library, you must first load it ... Requests to an API or SDK associated with the...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found