mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-24 17:41:34 +08:00
sinks: android: handle when message is not loggable (#2801)
Android logger (since API 30) checks the per-tag property `log.tag.<tag>` to determine if a log message is loggable. See https://developer.android.com/ndk/reference/group/logging#__android_log_is_loggable . For example, `__android_log_buf_write` for a VERBOSE message will call `__android_log_is_loggable` and return `-EPERM` if the log message will not be printed because `log.tag.<tag>` is set to `INFO`. Instead of erroring with the following error message, the Android sink should handle `-EPERM`. It is not an error to disable a log via the run-time property. ``` [*** LOG ERROR #0001 ***] [2023-06-29 00:50:26] [logcat] logging to Android failed: Unknown error -1 [/path/to/file.cpp(123)] ```
This commit is contained in:
parent
4b8ff51a29
commit
01b3724c48
@ -56,6 +56,10 @@ protected:
|
||||
|
||||
// See system/core/liblog/logger_write.c for explanation of return value
|
||||
int ret = android_log(priority, tag_.c_str(), msg_output);
|
||||
if (ret == -EPERM)
|
||||
{
|
||||
return; // !__android_log_is_loggable
|
||||
}
|
||||
int retry_count = 0;
|
||||
while ((ret == -11 /*EAGAIN*/) && (retry_count < SPDLOG_ANDROID_RETRIES))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user