Implement logging purely in Rust

This commit is contained in:
topjohnwu
2023-05-09 18:54:38 -07:00
parent 8c2ad3883a
commit 7518092ad2
17 changed files with 433 additions and 228 deletions
+31
View File
@@ -0,0 +1,31 @@
use crate::logging::{magisk_logging, zygisk_logging};
use std::cell::RefCell;
use std::fs::File;
use std::sync::{Mutex, OnceLock};
// Global magiskd singleton
pub static MAGISKD: OnceLock<MagiskD> = OnceLock::new();
#[derive(Default)]
pub struct MagiskD {
pub logd: Mutex<RefCell<Option<File>>>,
}
pub fn daemon_entry() {
let magiskd = MagiskD::default();
magiskd.start_log_daemon();
MAGISKD.set(magiskd).ok();
magisk_logging();
}
pub fn zygisk_entry() {
let magiskd = MagiskD::default();
MAGISKD.set(magiskd).ok();
zygisk_logging();
}
pub fn get_magiskd() -> &'static MagiskD {
MAGISKD.get().unwrap()
}
impl MagiskD {}