mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
config log
This commit is contained in:
parent
77aa18d737
commit
a242b9f036
@ -17,15 +17,15 @@ class RustSDKInitTask extends LaunchTask {
|
||||
|
||||
Bloc.observer = ApplicationBlocObserver();
|
||||
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
final documentPath = directory.path;
|
||||
final flowySandbox = Directory('$documentPath/flowy');
|
||||
switch (context.env) {
|
||||
case IntegrationEnv.dev:
|
||||
await context.getIt<FlowySDK>().init(Directory('./temp/flowy_dev'));
|
||||
// await context.getIt<FlowySDK>().init(Directory('./temp/flowy_dev'));
|
||||
await context.getIt<FlowySDK>().init(flowySandbox);
|
||||
break;
|
||||
case IntegrationEnv.pro:
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
final documentPath = directory.path;
|
||||
|
||||
final flowySandbox = Directory('$documentPath/flowy');
|
||||
await context.getIt<FlowySDK>().init(flowySandbox);
|
||||
break;
|
||||
default:
|
||||
|
1
rust-lib/.gitignore
vendored
1
rust-lib/.gitignore
vendored
@ -8,3 +8,4 @@ Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
**/**/*.log*
|
@ -27,7 +27,7 @@ serde_json = {version = "1.0"}
|
||||
|
||||
flowy-sys = {path = "../flowy-sys"}
|
||||
flowy-sdk = {path = "../flowy-sdk"}
|
||||
flowy-log = {path = "../flowy-log"}
|
||||
|
||||
|
||||
#[features]
|
||||
#use_serde = ["bincode"]
|
||||
|
@ -82,7 +82,7 @@ where
|
||||
},
|
||||
Err(e) => {
|
||||
if let Some(msg) = e.downcast_ref::<&str>() {
|
||||
log::error!("[FFI]: ❌ {:?}", msg);
|
||||
log::error!("[FFI]: {:?}", msg);
|
||||
} else {
|
||||
log::error!("[FFI]: allo_isolate post panic");
|
||||
}
|
||||
|
@ -6,11 +6,13 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
#tracing = { version = "0.1" }
|
||||
tracing = { version = "0.1", features = ["max_level_debug", "release_max_level_warn"] }
|
||||
tracing = { version = "0.1" }
|
||||
tracing-log = { version = "0.1.1"}
|
||||
tracing-futures = "0.2.4"
|
||||
tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter"] }
|
||||
tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter", "ansi", "json"] }
|
||||
tracing-bunyan-formatter = "0.2.2"
|
||||
tracing-appender = "0.1"
|
||||
log = "0.4.14"
|
||||
log = "0.4.14"
|
||||
|
||||
[features]
|
||||
use_bunyan = []
|
@ -13,19 +13,16 @@ pub struct FlowyLogBuilder {
|
||||
name: String,
|
||||
env_filter: String,
|
||||
directory: String,
|
||||
file_appender: RollingFileAppender,
|
||||
}
|
||||
|
||||
impl FlowyLogBuilder {
|
||||
pub fn new(name: &str, directory: impl AsRef<Path>) -> Self {
|
||||
let directory = directory.as_ref().to_str().unwrap().to_owned();
|
||||
let local_file_name = format!("{}.log", name);
|
||||
let file_appender = tracing_appender::rolling::hourly(directory.clone(), local_file_name);
|
||||
|
||||
FlowyLogBuilder {
|
||||
name: name.to_owned(),
|
||||
env_filter: "Info".to_owned(),
|
||||
directory,
|
||||
file_appender,
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,29 +34,36 @@ impl FlowyLogBuilder {
|
||||
pub fn build(self) -> std::result::Result<(), String> {
|
||||
let env_filter = EnvFilter::new(self.env_filter);
|
||||
|
||||
let (non_blocking, _guard) = tracing_appender::non_blocking(self.file_appender);
|
||||
|
||||
let formatting_layer = BunyanFormattingLayer::new(self.name, std::io::stdout);
|
||||
|
||||
let mut subscriber = tracing_subscriber::fmt()
|
||||
.with_target(false)
|
||||
.with_max_level(tracing::Level::TRACE)
|
||||
.with_writer(std::io::stdout)
|
||||
.with_writer(std::io::stderr)
|
||||
.with_thread_ids(false)
|
||||
.with_target(false)
|
||||
// .with_writer(non_blocking)
|
||||
.compact()
|
||||
.finish()
|
||||
.with(env_filter)
|
||||
.with(JsonStorageLayer)
|
||||
.with(formatting_layer);
|
||||
.with(env_filter);
|
||||
|
||||
if cfg!(feature = "use_bunyan") {
|
||||
let formatting_layer = BunyanFormattingLayer::new(self.name.clone(), std::io::stdout);
|
||||
|
||||
let local_file_name = format!("{}.log", &self.name);
|
||||
let file_appender =
|
||||
tracing_appender::rolling::daily(self.directory.clone(), local_file_name);
|
||||
let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
|
||||
|
||||
let _ = set_global_default(subscriber.with(JsonStorageLayer).with(formatting_layer))
|
||||
.map_err(|e| format!("{:?}", e))?;
|
||||
} else {
|
||||
let _ = set_global_default(subscriber).map_err(|e| format!("{:?}", e))?;
|
||||
}
|
||||
let _ = LogTracer::builder()
|
||||
.with_max_level(LevelFilter::Trace)
|
||||
.init()
|
||||
.map_err(|e| format!("{:?}", e))
|
||||
.unwrap();
|
||||
let _ = set_global_default(subscriber).map_err(|e| format!("{:?}", e))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
flowy-sys = { path = "../flowy-sys", features = ["use_tracing"]}
|
||||
flowy-log = { path = "../flowy-log" }
|
||||
flowy-log = { path = "../flowy-log", features = ["use_bunyan"] }
|
||||
flowy-user = { path = "../flowy-user" }
|
||||
tracing = { version = "0.1" }
|
||||
log = "0.4.14"
|
||||
|
@ -162,6 +162,14 @@ impl Service<DispatchRequest> for DispatchService {
|
||||
type Error = SystemError;
|
||||
type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "use_tracing",
|
||||
tracing::instrument(
|
||||
name = "DispatchService",
|
||||
level = "debug",
|
||||
skip(self, dispatch_request)
|
||||
)
|
||||
)]
|
||||
fn call(&self, dispatch_request: DispatchRequest) -> Self::Future {
|
||||
let module_map = self.module_map.clone();
|
||||
let (request, callback) = dispatch_request.into_parts();
|
||||
|
@ -164,8 +164,6 @@ impl Service<ModuleRequest> for ModuleService {
|
||||
type Error = SystemError;
|
||||
type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
|
||||
|
||||
// #[cfg_attr(feature = "use_tracing", xxx)]
|
||||
#[tracing::instrument(name = "Module Service", level = "debug", skip(self))]
|
||||
fn call(&self, request: ModuleRequest) -> Self::Future {
|
||||
match self.service_map.get(&request.event()) {
|
||||
Some(factory) => {
|
||||
|
@ -67,8 +67,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg_attr(feature = "use_serde", #[serde(serialize_with =
|
||||
// "serialize_data")])]
|
||||
#[cfg(feature = "use_serde")]
|
||||
fn serialize_data<S>(data: &ResponseData, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user