mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
Reduce cpp logging overhead
This commit is contained in:
parent
7518092ad2
commit
583ffc8177
@ -25,7 +25,7 @@ pub mod ffi {
|
||||
}
|
||||
|
||||
extern "Rust" {
|
||||
fn log_with_rs(level: LogLevel, msg: &str);
|
||||
fn log_with_rs(level: LogLevel, msg: &[u8]);
|
||||
fn exit_on_error(b: bool);
|
||||
fn set_log_level_state(level: LogLevel, enabled: bool);
|
||||
fn cmdline_logging();
|
||||
|
@ -14,7 +14,7 @@ using namespace std;
|
||||
static int fmt_and_log_with_rs(LogLevel level, const char *fmt, va_list ap) {
|
||||
char buf[4096];
|
||||
int ret = vssprintf(buf, sizeof(buf), fmt, ap);
|
||||
log_with_rs(level, rust::Str(buf, ret));
|
||||
log_with_rs(level, rust::Slice(reinterpret_cast<const uint8_t *>(buf), ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,12 @@ pub fn set_log_level_state(level: LogLevel, enabled: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn log_with_rs(level: LogLevel, msg: &str) {
|
||||
pub fn log_with_rs(level: LogLevel, msg: &[u8]) {
|
||||
let logger = unsafe { LOGGER };
|
||||
if (logger.flags & level.to_disable_flag()) != 0 {
|
||||
return;
|
||||
}
|
||||
(logger.write)(level, msg.as_bytes());
|
||||
(logger.write)(level, msg);
|
||||
if level == LogLevel::Error && (logger.flags & LogFlag::ExitOnError) != 0 {
|
||||
exit(1);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ fn zygisk_log_write(prio: i32, msg: &[u8]) {
|
||||
|
||||
// Consume SIGPIPE if exists, then restore mask
|
||||
unsafe {
|
||||
let mut ts: timespec = std::mem::zeroed();
|
||||
let ts: timespec = std::mem::zeroed();
|
||||
sigtimedwait(&mask, null_mut(), &ts);
|
||||
pthread_sigmask(SIG_SETMASK, &orig_mask, null_mut());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user