move toward api logging
This commit is contained in:
@@ -427,14 +427,36 @@ impl AttachmentState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum VeilidLogLevel {
|
||||
Error,
|
||||
Warn,
|
||||
Info,
|
||||
Debug,
|
||||
Trace,
|
||||
}
|
||||
impl VeilidLogLevel {
|
||||
fn from_core(level: veilid_core::VeilidLogLevel) -> Self {
|
||||
match level {
|
||||
veilid_core::VeilidLogLevel::Error => VeilidLogLevel::Error,
|
||||
veilid_core::VeilidLogLevel::Warn => VeilidLogLevel::Warn,
|
||||
veilid_core::VeilidLogLevel::Info => VeilidLogLevel::Info,
|
||||
veilid_core::VeilidLogLevel::Debug => VeilidLogLevel::Debug,
|
||||
veilid_core::VeilidLogLevel::Trace => VeilidLogLevel::Trace,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum VeilidUpdate {
|
||||
Log(VeilidLogLevel, String),
|
||||
Attachment(AttachmentState),
|
||||
}
|
||||
|
||||
impl VeilidUpdate {
|
||||
fn from_core(veilid_update: veilid_core::VeilidUpdate) -> Self {
|
||||
match veilid_update {
|
||||
veilid_core::VeilidUpdate::Log(ll, s) => Self::Log(VeilidLogLevel::from_core(ll), s),
|
||||
veilid_core::VeilidUpdate::Attachment(attachment) => {
|
||||
Self::Attachment(AttachmentState::from_core(attachment))
|
||||
}
|
||||
|
@@ -491,6 +491,19 @@ impl support::IntoDart for AttachmentState {
|
||||
}
|
||||
}
|
||||
|
||||
impl support::IntoDart for VeilidLogLevel {
|
||||
fn into_dart(self) -> support::DartCObject {
|
||||
match self {
|
||||
Self::Error => 0,
|
||||
Self::Warn => 1,
|
||||
Self::Info => 2,
|
||||
Self::Debug => 3,
|
||||
Self::Trace => 4,
|
||||
}
|
||||
.into_dart()
|
||||
}
|
||||
}
|
||||
|
||||
impl support::IntoDart for VeilidState {
|
||||
fn into_dart(self) -> support::DartCObject {
|
||||
vec![self.attachment.into_dart()].into_dart()
|
||||
@@ -501,7 +514,10 @@ impl support::IntoDartExceptPrimitive for VeilidState {}
|
||||
impl support::IntoDart for VeilidUpdate {
|
||||
fn into_dart(self) -> support::DartCObject {
|
||||
match self {
|
||||
Self::Attachment(field0) => vec![0.into_dart(), field0.into_dart()],
|
||||
Self::Log(field0, field1) => {
|
||||
vec![0.into_dart(), field0.into_dart(), field1.into_dart()]
|
||||
}
|
||||
Self::Attachment(field0) => vec![1.into_dart(), field0.into_dart()],
|
||||
}
|
||||
.into_dart()
|
||||
}
|
||||
|
@@ -3,35 +3,16 @@ mod bridge_generated;
|
||||
|
||||
use cfg_if::*;
|
||||
|
||||
xxx make this work
|
||||
|
||||
#[cfg(all(target_os = "android", feature = "android_tests"))]
|
||||
#[cfg(target_os = "android")]
|
||||
use jni::{objects::JClass, objects::JObject, JNIEnv};
|
||||
|
||||
#[cfg(all(target_os = "android", feature = "android_tests"))]
|
||||
#[cfg(target_os = "android")]
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "system" fn Java_com_veilid_veilidcore_veilidcore_1android_1tests_MainActivity_run_1tests(
|
||||
pub extern "system" fn Java_com_veilid_veilid_VeilidPlugin_init_1android(
|
||||
env: JNIEnv,
|
||||
_class: JClass,
|
||||
ctx: JObject,
|
||||
) {
|
||||
crate::intf::utils::android::veilid_core_setup_android(env, ctx, "veilid_core", Level::Trace);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "ios")]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn run_veilid_core_tests(app_name: c_str) {
|
||||
let log_path: std::path::PathBuf = [
|
||||
std::env::var("HOME").unwrap().as_str(),
|
||||
"Documents",
|
||||
"veilid-core.log",
|
||||
]
|
||||
.iter()
|
||||
.collect();
|
||||
crate::intf::utils::setup::veilid_core_setup(
|
||||
"veilid-core",
|
||||
Some(Level::Trace),
|
||||
Some((Level::Trace, log_path.as_path())),
|
||||
);
|
||||
crate::intf::utils::android::veilid_core_setup_android_no_log(env, ctx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user