Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom logger not working? #1010

Closed
SpencerCDixon opened this issue Apr 9, 2020 · 6 comments
Closed

Custom logger not working? #1010

SpencerCDixon opened this issue Apr 9, 2020 · 6 comments
Assignees
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@SpencerCDixon
Copy link

SpencerCDixon commented Apr 9, 2020

Which version of the Ably SDK are you using?

E.g. 1.21.1

On which platform does the issue happen?

macOS 10.14/15

Are you using Carthage?

0.34.0

Which version of Xcode are you using?

11.3

What did you do?

Using a custom logger doesn't appear to be working. I'm probably doing something really dumb and silly so I apologize in advance.

Here is my code:

Custom logger with a breakpoint
Screen Shot 2020-04-09 at 12 53 16 PM

Create instance

...
self.logHandler = MyLogger()
...

Setting in my client options:

let options = ARTClientOptions()
options.logLevel = .verbose
options.logHandler = self.logHandler
let ably = ARTRealtime(options: options)

Logging continues to happen to console and my breakpoint in my custom logger never gets hit.

Something obvious I'm missing or is this a regression in the library?

EDIT:
I forked the project and added NSLog's in the ARTRest initWithOptions. I'm seeing my custom logger get set just not receiving any messages :(

@QuintinWillison
Copy link
Contributor

Hi @SpencerCDixon - I've just had a go myself and you're on to something! This looks like a bug.

You're correctly overriding the method we expose in our interface (being log:withLevel) but the internal implementation appears to be circumventing your override and calling an internal method instead.

I'll get this fixed but in the meantime I was able (in Objective-C for the moment) prove that I can get my override called if I implement using the selector log:level, not log:withLevel. I've not yet tested from Swift but that might help you.

@QuintinWillison QuintinWillison added the bug Something isn't working. It's clear that this does need to be fixed. label Apr 9, 2020
@SpencerCDixon
Copy link
Author

Thanks Quintin! Let me know when you have a fix! In the meantime, I can try getting the Objective-C solution working

We have some customers having issues with the client getting in an infinite reconnect loop. I need to hook your logger into ours so we can give you debug info to resolve those issues

@QuintinWillison
Copy link
Contributor

I've pushed up a tentative fix for you, @SpencerCDixon ... if you wouldn't mind replacing the Ably entry in your Cartfile with:

github "ably/ably-cocoa" "feature/bugfix-1010"

and letting me know if your logger works now?

We can then work on getting a formal release out with this fix next week.

@SpencerCDixon
Copy link
Author

Good news! The breakpoints are now being hit. Thank you for fixing this so quickly I really appreciate it.

I'll work off your branch until an official release goes out

@QuintinWillison QuintinWillison self-assigned this Apr 9, 2020
@QuintinWillison
Copy link
Contributor

Thanks for letting me know so quickly, @SpencerCDixon. I'm glad we could be of assistance! 😁

@QuintinWillison
Copy link
Contributor

Hi @SpencerCDixon - the release was made this morning: v1.1.22

Now that the PR has been merged, the branch has also been deleted. I'm hoping you can simply move to using the release rather than the branch and, thus, that this will cause you no problems. If you do, however, need me to restore the branch temporarily to aid your transition then just let me know.

Thanks for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

2 participants