mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: add log
This commit is contained in:
parent
2623974def
commit
f841587c27
@ -93,6 +93,8 @@ impl fmt::Display for FlowyError {
|
|||||||
impl lib_dispatch::Error for FlowyError {
|
impl lib_dispatch::Error for FlowyError {
|
||||||
fn as_response(&self) -> EventResponse {
|
fn as_response(&self) -> EventResponse {
|
||||||
let bytes: Bytes = self.clone().try_into().unwrap();
|
let bytes: Bytes = self.clone().try_into().unwrap();
|
||||||
|
|
||||||
|
println!("Serialize FlowyError: {:?} to event response", self);
|
||||||
ResponseBuilder::Err().data(bytes).build()
|
ResponseBuilder::Err().data(bytes).build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,9 @@ impl AppController {
|
|||||||
let app = transaction.read_app(¶ms.value)?;
|
let app = transaction.read_app(¶ms.value)?;
|
||||||
let trash_ids = self.trash_controller.read_trash_ids(&transaction)?;
|
let trash_ids = self.trash_controller.read_trash_ids(&transaction)?;
|
||||||
if trash_ids.contains(&app.id) {
|
if trash_ids.contains(&app.id) {
|
||||||
return Err(FlowyError::record_not_found());
|
return Err(
|
||||||
|
FlowyError::record_not_found().context(format!("Can not find the app:{}", params.value))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Ok(app)
|
Ok(app)
|
||||||
})
|
})
|
||||||
|
@ -44,7 +44,7 @@ pub(crate) async fn update_app_handler(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "trace", skip(data, app_controller, view_controller))]
|
#[tracing::instrument(level = "info", skip(data, app_controller, view_controller), err)]
|
||||||
pub(crate) async fn read_app_handler(
|
pub(crate) async fn read_app_handler(
|
||||||
data: Data<AppIdPB>,
|
data: Data<AppIdPB>,
|
||||||
app_controller: AppData<Arc<AppController>>,
|
app_controller: AppData<Arc<AppController>>,
|
||||||
|
@ -83,15 +83,21 @@ where
|
|||||||
R: FromBytes,
|
R: FromBytes,
|
||||||
{
|
{
|
||||||
let response = self.get_response();
|
let response = self.get_response();
|
||||||
match response.parse::<R, E>() {
|
match response.clone().parse::<R, E>() {
|
||||||
Ok(Ok(data)) => data,
|
Ok(Ok(data)) => data,
|
||||||
Ok(Err(e)) => {
|
Ok(Err(e)) => {
|
||||||
panic!("Parser {:?} failed: {:?}", std::any::type_name::<R>(), e)
|
panic!(
|
||||||
|
"Parser {:?} failed: {:?}, response {:?}",
|
||||||
|
std::any::type_name::<R>(),
|
||||||
|
e,
|
||||||
|
response
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Err(e) => panic!(
|
Err(e) => panic!(
|
||||||
"Internal error: {:?}, parser {:?} failed",
|
"Dispatch {:?} failed: {:?}, response {:?}",
|
||||||
e,
|
|
||||||
std::any::type_name::<R>(),
|
std::any::type_name::<R>(),
|
||||||
|
e,
|
||||||
|
response
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ impl UserDB {
|
|||||||
Some(database) => return Ok(database.get_pool()),
|
Some(database) => return Ok(database.get_pool()),
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::trace!("open user db {}", user_id);
|
|
||||||
let dir = format!("{}/{}", self.db_dir, user_id);
|
let dir = format!("{}/{}", self.db_dir, user_id);
|
||||||
|
tracing::trace!("open user db {} at path: {}", user_id, dir);
|
||||||
let db = flowy_database::init(&dir).map_err(|e| {
|
let db = flowy_database::init(&dir).map_err(|e| {
|
||||||
log::error!("open user: {} db failed, {:?}", user_id, e);
|
log::error!("open user: {} db failed, {:?}", user_id, e);
|
||||||
FlowyError::internal().context(e)
|
FlowyError::internal().context(e)
|
||||||
|
@ -14,7 +14,12 @@ where
|
|||||||
fn into_bytes(self) -> Result<Bytes, DispatchError> {
|
fn into_bytes(self) -> Result<Bytes, DispatchError> {
|
||||||
match self.try_into() {
|
match self.try_into() {
|
||||||
Ok(data) => Ok(data),
|
Ok(data) => Ok(data),
|
||||||
Err(e) => Err(InternalError::ProtobufError(format!("{:?}", e)).into()),
|
Err(e) => Err(InternalError::ProtobufError(format!(
|
||||||
|
"Serial {:?} to bytes failed:{:?}",
|
||||||
|
std::any::type_name::<T>(),
|
||||||
|
e
|
||||||
|
))
|
||||||
|
.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,10 @@ where
|
|||||||
{
|
{
|
||||||
fn respond_to(self, _request: &EventRequest) -> EventResponse {
|
fn respond_to(self, _request: &EventRequest) -> EventResponse {
|
||||||
match self.into_inner().into_bytes() {
|
match self.into_inner().into_bytes() {
|
||||||
Ok(bytes) => ResponseBuilder::Ok().data(bytes).build(),
|
Ok(bytes) => {
|
||||||
|
log::trace!("Serialize Data: {:?} to event response", std::any::type_name::<T>());
|
||||||
|
return ResponseBuilder::Ok().data(bytes).build();
|
||||||
|
}
|
||||||
Err(e) => e.into(),
|
Err(e) => e.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +89,11 @@ where
|
|||||||
T: FromBytes,
|
T: FromBytes,
|
||||||
{
|
{
|
||||||
match payload {
|
match payload {
|
||||||
Payload::None => Err(InternalError::UnexpectedNone("Parse fail, expected payload".to_string()).into()),
|
Payload::None => Err(InternalError::UnexpectedNone(format!(
|
||||||
|
"Parse fail, expected payload:{:?}",
|
||||||
|
std::any::type_name::<T>()
|
||||||
|
))
|
||||||
|
.into()),
|
||||||
Payload::Bytes(bytes) => {
|
Payload::Bytes(bytes) => {
|
||||||
let data = T::parse_from_bytes(bytes.clone())?;
|
let data = T::parse_from_bytes(bytes.clone())?;
|
||||||
Ok(Data(data))
|
Ok(Data(data))
|
||||||
|
@ -54,16 +54,18 @@ impl EventDispatcher {
|
|||||||
callback: Some(Box::new(callback)),
|
callback: Some(Box::new(callback)),
|
||||||
};
|
};
|
||||||
let join_handle = dispatch.runtime.spawn(async move {
|
let join_handle = dispatch.runtime.spawn(async move {
|
||||||
service
|
service.call(service_ctx).await.unwrap_or_else(|e| {
|
||||||
.call(service_ctx)
|
tracing::error!("Dispatch runtime error: {:?}", e);
|
||||||
.await
|
InternalError::Other(format!("{:?}", e)).as_response()
|
||||||
.unwrap_or_else(|e| InternalError::Other(format!("{:?}", e)).as_response())
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
DispatchFuture {
|
DispatchFuture {
|
||||||
fut: Box::pin(async move {
|
fut: Box::pin(async move {
|
||||||
join_handle.await.unwrap_or_else(|e| {
|
join_handle.await.unwrap_or_else(|e| {
|
||||||
let error = InternalError::JoinError(format!("EVENT_DISPATCH join error: {:?}", e));
|
let msg = format!("EVENT_DISPATCH join error: {:?}", e);
|
||||||
|
tracing::error!("{}", msg);
|
||||||
|
let error = InternalError::JoinError(msg);
|
||||||
error.as_response()
|
error.as_response()
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user