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
React Native support #130
Comments
Hmm, I'm not sure I'm afraid, I've never used React Native. Do the corresponding Can you log the value of the methods that don't work? E.g. Loglevel makes a lot of effort to work even in old browsers from before localStorage was available, so I'd be surprised if that was the issue, but without knowing much about React Native it's hard to tell. |
The methods that don't work log out as |
And that's after calling The code is pretty simple. I don't have a react native environment set up, but if you debug through this, what should happen is that it calls Looking through the code, I can't see where that could possibly go wrong for React Native, but who knows. If you step through it though, you should see somewhere there that no-op gets assigned incorrectly somehow, which would cause this. Sorry I can't be more help. Once you've got a clear cause though, or a PR, let me know and I'd love to get this fixed. |
Sorry for the delayed reply, If I get a chance I will investigate this and see if I can create a PR, But I'm not sure how soon I will be able to get to it. |
@vidhill
|
Hi @rahamin1, I'm afraid I'm not sure! I've never used React Native myself. Loglevel acts as a simple JS wrapper around Sorry I can't be more specific. Do reply here if loglevel works for you in React Native though, and if you discover the answers to those questions (or hit specific issues), since I'm sure other people will come across this thread with the same questions too. |
@rahamin1 We are using loglevel successfully in a React Native project, I can answer your questions:
We need to re-init the logger(s) (we use multiple named loggers) after React Native starts because React Native adds hooks into console.warn and console.error for the "redbox" functionality. We call this from our main Running this earlier in
Nothing special here: We use debug, info, warn, error methods but not trace.
The logs show up in the Xcode console output or in the Chrome console when debugging (line numbers work). For our staging builds we replace |
@pimterry Open to a PR that adds some of these React Native notes to the readme? When I saw this issue as open from 2019 I assumed that React Native was not supported, but it seems like there is a working option, just that it requires some magic to workaround React Native's non standard console behaviour. Would it therefore make sense to close this issue? |
Good point @chmac! Yes, a PR that documents the above would be happily received. I think the effective summary is that you just need to call |
I don't exactly see why it shouldn't but this module appears not to work with react native,
Well,
log.warn()
andlog.error()
work, but nothing below that level gets output,-even if I call
loglevel.setDefaultLevel('trace');
orloglevel.setLevel('trace');
log.debug()
andlog.info()
still equalnoop
I don't know if it has something to do with the persisting, as react-native had no localstorage..
The text was updated successfully, but these errors were encountered: