AppFlowy/rust-lib/flowy-sdk/src/lib.rs

28 lines
741 B
Rust
Raw Normal View History

2021-06-30 15:11:27 +00:00
pub mod module;
pub use module::*;
2021-07-08 13:23:44 +00:00
use flowy_dispatch::prelude::*;
2021-06-30 15:11:27 +00:00
use module::build_modules;
2021-07-13 05:14:49 +00:00
use std::sync::atomic::{AtomicBool, Ordering};
2021-07-09 15:31:44 +00:00
2021-07-13 05:14:49 +00:00
static INIT_LOG: AtomicBool = AtomicBool::new(false);
2021-06-28 15:58:43 +00:00
pub struct FlowySDK {}
impl FlowySDK {
2021-07-13 05:14:49 +00:00
pub fn init_log(directory: &str) {
if !INIT_LOG.load(Ordering::SeqCst) {
INIT_LOG.store(true, Ordering::SeqCst);
flowy_log::init_log("flowy", directory, "Debug").unwrap();
}
}
2021-06-28 15:58:43 +00:00
2021-07-02 12:47:52 +00:00
pub fn init(path: &str) {
tracing::info!("🔥 Root path: {}", path);
flowy_infra::kv::KVStore::init(path);
2021-07-09 15:31:44 +00:00
let config = ModuleConfig {
root: path.to_string(),
};
EventDispatch::construct(|| build_modules(config));
2021-06-30 15:11:27 +00:00
}
2021-06-28 15:58:43 +00:00
}