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
Option to filter logs by priority #348
Conversation
Thanks for all this work @philips77 Have you memory profiled this? My fear is that, although this allows log filtering, it doesn't necessarily prevent the issue of object allocation. My understanding of how lambdas work in Java is that each lambda potentially allocates a new object that captures the closure information. Unfortunately, the only way I've successfully implemented memory efficient log filtering is by using if statements at the site of logging. |
I precisely wanted to
as it was tempting. However, it's still way faster than before. I ca refactor it once again to add tons of |
This change improves performance, as with disabled logs the byte arrays are not converted to String just for logging purposes.
a169581
to
d361279
Compare
@philips77 are you able to memory profile this before doing all that work? |
Hello, Allocating objects for lambdas should still be much better than the previous solution. I'll leave the current implementation for now, as we're thinking about redoing this project in Kotlin anyway. I'll add some more features, check reported issues and will release it as 2.4. |
This PR fixes #346.
The new method
Android-BLE-Library/ble/src/main/java/no/nordicsemi/android/ble/utils/ILogger.java
Lines 32 to 37 in e55d46b
in
BleManager
andBleServerManager
allows to omit creating and logging logs on lower priorities. By default, logs from levelsLog.INFO
and higher will be logged, which is a change in default behavior. Previously all logs were produced, even if later ignored.To disable logging, return
Log.ERROR
orLog.ASSERT
from those methods. To restore previous behavior, returnLog.VERBOSE
.