mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
[android] Use android logger (#585)
This commit is contained in:
parent
b5cbbb7f8f
commit
d8dfbbe2d2
1 changed files with 30 additions and 0 deletions
|
@ -16,8 +16,13 @@
|
|||
#include "tr-assert.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
|
||||
tr_log_level __tr_message_level = TR_LOG_ERROR;
|
||||
|
||||
static bool myQueueEnabled = false;
|
||||
|
@ -228,8 +233,32 @@ void tr_logAddMessage(char const* file, int line, tr_log_level level, char const
|
|||
OutputDebugStringA(buf);
|
||||
}
|
||||
|
||||
#elif defined(__ANDROID__)
|
||||
|
||||
int prio;
|
||||
|
||||
switch (level) {
|
||||
case TR_LOG_ERROR:
|
||||
prio = ANDROID_LOG_ERROR;
|
||||
break;
|
||||
case TR_LOG_INFO:
|
||||
prio = ANDROID_LOG_INFO;
|
||||
break;
|
||||
case TR_LOG_DEBUG:
|
||||
prio = ANDROID_LOG_DEBUG;
|
||||
break;
|
||||
default:
|
||||
prio = ANDROID_LOG_VERBOSE;
|
||||
}
|
||||
|
||||
#ifdef NDEBUG
|
||||
__android_log_print(prio, "transmission", "%s", buf);
|
||||
#else
|
||||
__android_log_print(prio, "transmission", "[%s:%d] %s", file, line, buf);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
if (!tr_str_is_empty(buf))
|
||||
{
|
||||
if (tr_logGetQueueEnabled())
|
||||
|
@ -275,6 +304,7 @@ void tr_logAddMessage(char const* file, int line, tr_log_level level, char const
|
|||
tr_sys_file_flush(fp, nullptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
errno = err;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue