Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
122b4d66
Commit
122b4d66
authored
May 10, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Android logging out of libutils
parent
0f8f4e36
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
49 deletions
+27
-49
daemon.cpp
native/jni/core/daemon.cpp
+14
-3
logging.hpp
native/jni/utils/include/logging.hpp
+0
-1
logging.cpp
native/jni/utils/logging.cpp
+13
-45
No files found.
native/jni/core/daemon.cpp
View file @
122b4d66
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
#include <libgen.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <android/log.h>
#include <magisk.hpp>
#include <utils.hpp>
...
...
@@ -112,6 +110,19 @@ static void *request_handler(void *args) {
return
nullptr
;
}
static
void
android_logging
()
{
static
constexpr
char
TAG
[]
=
"Magisk"
;
#ifdef MAGISK_DEBUG
log_cb
.
d
=
[](
auto
fmt
,
auto
ap
){
return
__android_log_vprint
(
ANDROID_LOG_DEBUG
,
TAG
,
fmt
,
ap
);
};
#else
log_cb
.
d
=
nop_log
;
#endif
log_cb
.
i
=
[](
auto
fmt
,
auto
ap
){
return
__android_log_vprint
(
ANDROID_LOG_INFO
,
TAG
,
fmt
,
ap
);
};
log_cb
.
w
=
[](
auto
fmt
,
auto
ap
){
return
__android_log_vprint
(
ANDROID_LOG_WARN
,
TAG
,
fmt
,
ap
);
};
log_cb
.
e
=
[](
auto
fmt
,
auto
ap
){
return
__android_log_vprint
(
ANDROID_LOG_ERROR
,
TAG
,
fmt
,
ap
);
};
log_cb
.
ex
=
nop_ex
;
}
static
void
daemon_entry
(
int
ppid
)
{
android_logging
();
...
...
native/jni/utils/include/logging.hpp
View file @
122b4d66
...
...
@@ -33,7 +33,6 @@ int nop_log(const char *fmt, va_list ap);
void
nop_ex
(
int
i
);
void
no_logging
();
void
android_logging
();
void
cmdline_logging
();
int
log_handler
(
log_type
t
,
const
char
*
fmt
,
...);
...
...
native/jni/utils/logging.cpp
View file @
122b4d66
#include <stdio.h>
#include <stdlib.h>
#include <android/log.h>
#include <logging.hpp>
#include <flags.h>
int
nop_log
(
const
char
*
fmt
,
va_list
ap
)
{
return
0
;
...
...
@@ -27,36 +25,6 @@ void no_logging() {
log_cb
.
ex
=
nop_ex
;
}
#define LOG_TAG "Magisk"
[[
maybe_unused
]]
static
int
log_d
(
const
char
*
fmt
,
va_list
ap
)
{
return
__android_log_vprint
(
ANDROID_LOG_DEBUG
,
LOG_TAG
,
fmt
,
ap
);
}
static
int
log_i
(
const
char
*
fmt
,
va_list
ap
)
{
return
__android_log_vprint
(
ANDROID_LOG_INFO
,
LOG_TAG
,
fmt
,
ap
);
}
static
int
log_w
(
const
char
*
fmt
,
va_list
ap
)
{
return
__android_log_vprint
(
ANDROID_LOG_WARN
,
LOG_TAG
,
fmt
,
ap
);
}
static
int
log_e
(
const
char
*
fmt
,
va_list
ap
)
{
return
__android_log_vprint
(
ANDROID_LOG_ERROR
,
LOG_TAG
,
fmt
,
ap
);
}
void
android_logging
()
{
#ifdef MAGISK_DEBUG
log_cb
.
d
=
log_d
;
#else
log_cb
.
d
=
nop_log
;
#endif
log_cb
.
i
=
log_i
;
log_cb
.
w
=
log_w
;
log_cb
.
e
=
log_e
;
log_cb
.
ex
=
nop_ex
;
}
static
int
vprinte
(
const
char
*
fmt
,
va_list
ap
)
{
return
vfprintf
(
stderr
,
fmt
,
ap
);
}
...
...
@@ -74,19 +42,19 @@ int log_handler(log_type t, const char *fmt, ...) {
int
ret
=
0
;
va_start
(
argv
,
fmt
);
switch
(
t
)
{
case
L_DEBUG
:
ret
=
log_cb
.
d
(
fmt
,
argv
);
break
;
case
L_INFO
:
ret
=
log_cb
.
i
(
fmt
,
argv
);
break
;
case
L_WARN
:
ret
=
log_cb
.
w
(
fmt
,
argv
);
break
;
case
L_ERR
:
ret
=
log_cb
.
e
(
fmt
,
argv
);
log_cb
.
ex
(
1
);
break
;
case
L_DEBUG
:
ret
=
log_cb
.
d
(
fmt
,
argv
);
break
;
case
L_INFO
:
ret
=
log_cb
.
i
(
fmt
,
argv
);
break
;
case
L_WARN
:
ret
=
log_cb
.
w
(
fmt
,
argv
);
break
;
case
L_ERR
:
ret
=
log_cb
.
e
(
fmt
,
argv
);
log_cb
.
ex
(
1
);
break
;
}
va_end
(
argv
);
return
ret
;
...
...
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