Added more details in logger LWC's console statements #789
+129
−82
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.
When using the
logger
LWC and JavaScript console logging is enabled (viaLoggerSettings__c.IsJavaScriptConsoleLoggingEnabled__c
), Nebula Logger automatically calls functions in the browser'sconsole
so devs can easily see the generated log entry directly in their browser (instead of having to find it inLogEntry__c
). This PR improves the component log entry JSON that's printed usingconsole
statements - the stringified object now includes more details, such as details about the logged error/exception (when an error is logged), any tags added to the entry, and the user's localized version of the entry'stimestamp
.console
functions: now,console
functions are called with a 1 second delay (usingsetTimeout()
) so that additional details can be added to the log entry (using the builder methods) before the log entry is stringified & printed out. This may not be a perfect solution, but seems to work in most cases of using the JS builder methods.To show the difference in the changes, this JavaScript was used to generate some example log entries:
In the screenshot below, 2 versions of the output are shown:
setExceptionDetails()
.console
statements' outputconsole
output. This keeps the output slimmer & easier to read.new Date().toISOString()
) and in the user's local format (usingnew Date().toLocaleString()
). This makes it a little easier for devs to troubleshoot exactly when an entry was generated in their browser.