-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove global effects of setting logHandler and logLevel
Currently, if you create a client with logHandler and/or logLevel options, these options will affect all existing client objects. This means that code like the following doesn’t do what you’d expect — the log messages emitted by firstClient will say "secondClient": ``` const firstClient = new Realtime({ logHandler: (msg) => console.log("firstClient: ", msg), }) const secondClient = new Realtime({ logHandler: (msg) => console.log("secondClient: ", msg), }) ``` Here we fix this as much as we can within the limitations of the existing public API (see usage of defaultLogger). I _think_ that using the default logging config is the right thing to do in the situations where we have a standalone function or static method that doesn’t accept logging configuration, but you could also argue that we should instead maintain global effects for these usages and use the last-set logging configuration. I don’t think it hugely matters because we actually only end up falling back to defaultLogger in: - the tests (that’s fine, we’ll see the console output) - reporting failure of functions that are directly invoked by the user and which throw an error upon failure anyway (i.e. even if the log message doesn’t go where the user expected, they’ll still be informed of the event the message described) I’ve kept the Logger.logAction* static methods instead of changing them to instance methods, because that way they remain easy for our strip-logs plugin to target. Created #1766 for updating ably.com documentation. Resolves #156.
- Loading branch information
1 parent
eab98b9
commit 6fb6a6b
Showing
38 changed files
with
596 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.