Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
4d324546
Commit
4d324546
authored
May 27, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
android/LogListener: pass formatted message to OnLog()
parent
4db882f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
14 deletions
+10
-14
LogBackend.cxx
src/LogBackend.cxx
+7
-2
LogListener.cxx
src/android/LogListener.cxx
+2
-10
LogListener.hxx
src/android/LogListener.hxx
+1
-2
No files found.
src/LogBackend.cxx
View file @
4d324546
...
...
@@ -183,9 +183,14 @@ Log(LogLevel level, const Domain &domain, const char *msg) noexcept
#ifdef ANDROID
__android_log_print
(
ToAndroidLogLevel
(
level
),
"MPD"
,
"%s: %s"
,
domain
.
GetName
(),
msg
);
if
(
logListener
!=
nullptr
)
if
(
logListener
!=
nullptr
)
{
char
buffer
[
1024
];
snprintf
(
buffer
,
sizeof
(
buffer
),
"%s: %s"
,
domain
.
GetName
(),
msg
);
logListener
->
OnLog
(
Java
::
GetEnv
(),
ToAndroidLogLevel
(
level
),
"%s: %s"
,
domain
.
GetName
(),
msg
);
buffer
);
}
#else
if
(
level
<
log_threshold
)
...
...
src/android/LogListener.cxx
View file @
4d324546
...
...
@@ -20,8 +20,6 @@
#include "LogListener.hxx"
#include "java/Class.hxx"
#include "java/String.hxx"
#include "util/AllocatedString.hxx"
#include "util/FormatString.hxx"
LogListener
::
LogListener
(
JNIEnv
*
env
,
jobject
obj
)
noexcept
:
Java
::
GlobalObject
(
env
,
obj
)
...
...
@@ -33,16 +31,10 @@ LogListener::LogListener(JNIEnv *env, jobject obj) noexcept
}
void
LogListener
::
OnLog
(
JNIEnv
*
env
,
int
priority
,
const
char
*
fmt
,
...)
const
noexcept
LogListener
::
OnLog
(
JNIEnv
*
env
,
int
priority
,
const
char
*
msg
)
const
noexcept
{
assert
(
env
!=
nullptr
);
std
::
va_list
args
;
va_start
(
args
,
fmt
);
const
auto
log
=
FormatStringV
(
fmt
,
args
);
va_end
(
args
);
env
->
CallVoidMethod
(
Get
(),
onLogMethod
,
priority
,
Java
::
String
(
env
,
log
.
c_str
()
).
Get
());
Java
::
String
(
env
,
msg
).
Get
());
}
src/android/LogListener.hxx
View file @
4d324546
...
...
@@ -28,8 +28,7 @@ class LogListener : public Java::GlobalObject {
public
:
LogListener
(
JNIEnv
*
env
,
jobject
obj
)
noexcept
;
void
OnLog
(
JNIEnv
*
env
,
int
priority
,
const
char
*
fmt
,
...)
const
noexcept
;
void
OnLog
(
JNIEnv
*
env
,
int
priority
,
const
char
*
msg
)
const
noexcept
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment