fix(useLogger): remove '<empty string>', allow any args/string substitution #510
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.
Closes #508
Problem
useLogger().logError
was logging<empty string>
if only one argument was provided.Solution
Remove the special case for
error || ''
below. Instead, letconsole.error
handle all the arguments as it does by default.Problem
Console string substitution was not working with
useLogger().logError
anduseLogger().logWarning
.Solution
If the first arg is a string, concatenate the
logPrefix
to the first arg. And allowany
type (including strings, numbers) for subsequent args.Otherwise, avoid coercing the first argument to a string, as this will incorrectly trigger string substitution.
Problem
Could not console.error or console.warn
any
type, or any number of arguments. (E.g.,console.warn
accepts 1 to n number of arguments, which can be any object, butuserLogger().logWarning
only accepted 1string
.)Solution
Type check to enforce at least 1 argument but allow many. Allow
any
type of argument.