Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow for anonymous functions in logging calls.
The function is only called if the message is logged. (e.g. if the verbosity is turned up high enough.)
This allows for expensive operations to be avoided in cases where the logging won't happen.
The idea is that this provides a performance benefit. I don't know how "expensive" an operation must be
to actually realize a performance benefit, though.
I added an example in
server.ts...It's probably "expensive" to dump the configuration to JSON, then stringify that JSON for logging.
I originally implemented something similar in my 'digikam-connector' extension, where I used it to log the inputs/outputs of the extension hooks while I was developing and debugging. I figured that running
util.inspect()on everything was undesirable in a production environment, but didn't want to remove all my logging statements. So, this seemed like a good compromise.In my local testing, the typescript still compiles OK, and the messages from
server.tsprint out exactly as they did before.