mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: remove unused code & update log (#5194)
* chore: remove unused code & update log * chore: clippy * chore: log
This commit is contained in:
parent
275d0b2ac4
commit
9aaada961f
2
.github/workflows/flutter_ci.yaml
vendored
2
.github/workflows/flutter_ci.yaml
vendored
@ -200,6 +200,8 @@ jobs:
|
|||||||
run: cargo make pub_get
|
run: cargo make pub_get
|
||||||
|
|
||||||
- name: Run Flutter unit tests
|
- name: Run Flutter unit tests
|
||||||
|
env:
|
||||||
|
DISABLE_EVENT_LOG: true
|
||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
run: |
|
run: |
|
||||||
if [ "$RUNNER_OS" == "macOS" ]; then
|
if [ "$RUNNER_OS" == "macOS" ]; then
|
||||||
|
@ -8,7 +8,7 @@ edition = "2021"
|
|||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
collab = { version = "0.1.0", features = ["trace_transact"] }
|
collab = { version = "0.1.0" }
|
||||||
collab-plugins = { version = "0.1.0" }
|
collab-plugins = { version = "0.1.0" }
|
||||||
collab-entity = { version = "0.1.0" }
|
collab-entity = { version = "0.1.0" }
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
@ -49,12 +49,11 @@ pub(crate) async fn get_all_workspace_handler(
|
|||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip(folder), err)]
|
#[tracing::instrument(level = "debug", skip(folder), err)]
|
||||||
pub(crate) async fn get_workspace_views_handler(
|
pub(crate) async fn get_workspace_views_handler(
|
||||||
data: AFPluginData<GetWorkspaceViewPB>,
|
_data: AFPluginData<GetWorkspaceViewPB>,
|
||||||
folder: AFPluginState<Weak<FolderManager>>,
|
folder: AFPluginState<Weak<FolderManager>>,
|
||||||
) -> DataResult<RepeatedViewPB, FlowyError> {
|
) -> DataResult<RepeatedViewPB, FlowyError> {
|
||||||
let folder = upgrade_folder(folder)?;
|
let folder = upgrade_folder(folder)?;
|
||||||
let params: GetWorkspaceViewParams = data.into_inner().try_into()?;
|
let child_views = folder.get_workspace_public_views().await?;
|
||||||
let child_views = folder.get_workspace_public_views(¶ms.value).await?;
|
|
||||||
let repeated_view: RepeatedViewPB = child_views.into();
|
let repeated_view: RepeatedViewPB = child_views.into();
|
||||||
data_result_ok(repeated_view)
|
data_result_ok(repeated_view)
|
||||||
}
|
}
|
||||||
@ -75,8 +74,8 @@ pub(crate) async fn read_private_views_handler(
|
|||||||
folder: AFPluginState<Weak<FolderManager>>,
|
folder: AFPluginState<Weak<FolderManager>>,
|
||||||
) -> DataResult<RepeatedViewPB, FlowyError> {
|
) -> DataResult<RepeatedViewPB, FlowyError> {
|
||||||
let folder = upgrade_folder(folder)?;
|
let folder = upgrade_folder(folder)?;
|
||||||
let params: GetWorkspaceViewParams = data.into_inner().try_into()?;
|
let _params: GetWorkspaceViewParams = data.into_inner().try_into()?;
|
||||||
let child_views = folder.get_workspace_private_views(¶ms.value).await?;
|
let child_views = folder.get_workspace_private_views().await?;
|
||||||
let repeated_view: RepeatedViewPB = child_views.into();
|
let repeated_view: RepeatedViewPB = child_views.into();
|
||||||
data_result_ok(repeated_view)
|
data_result_ok(repeated_view)
|
||||||
}
|
}
|
||||||
@ -379,14 +378,6 @@ pub(crate) async fn get_folder_snapshots_handler(
|
|||||||
data_result_ok(RepeatedFolderSnapshotPB { items: snapshots })
|
data_result_ok(RepeatedFolderSnapshotPB { items: snapshots })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn reload_workspace_handler(
|
|
||||||
folder: AFPluginState<Weak<FolderManager>>,
|
|
||||||
) -> Result<(), FlowyError> {
|
|
||||||
let folder = upgrade_folder(folder)?;
|
|
||||||
folder.reload_workspace().await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip(data, folder), err)]
|
#[tracing::instrument(level = "debug", skip(data, folder), err)]
|
||||||
pub(crate) async fn update_view_visibility_status_handler(
|
pub(crate) async fn update_view_visibility_status_handler(
|
||||||
data: AFPluginData<UpdateViewVisibilityStatusPayloadPB>,
|
data: AFPluginData<UpdateViewVisibilityStatusPayloadPB>,
|
||||||
|
@ -38,7 +38,6 @@ pub fn init(folder: Weak<FolderManager>) -> AFPlugin {
|
|||||||
.event(FolderEvent::ReadRecentViews, read_recent_views_handler)
|
.event(FolderEvent::ReadRecentViews, read_recent_views_handler)
|
||||||
.event(FolderEvent::ToggleFavorite, toggle_favorites_handler)
|
.event(FolderEvent::ToggleFavorite, toggle_favorites_handler)
|
||||||
.event(FolderEvent::UpdateRecentViews, update_recent_views_handler)
|
.event(FolderEvent::UpdateRecentViews, update_recent_views_handler)
|
||||||
.event(FolderEvent::ReloadWorkspace, reload_workspace_handler)
|
|
||||||
.event(FolderEvent::ReadPrivateViews, read_private_views_handler)
|
.event(FolderEvent::ReadPrivateViews, read_private_views_handler)
|
||||||
.event(FolderEvent::ReadCurrentWorkspaceViews, get_current_workspace_views_handler)
|
.event(FolderEvent::ReadCurrentWorkspaceViews, get_current_workspace_views_handler)
|
||||||
.event(FolderEvent::UpdateViewVisibilityStatus, update_view_visibility_status_handler)
|
.event(FolderEvent::UpdateViewVisibilityStatus, update_view_visibility_status_handler)
|
||||||
@ -163,9 +162,6 @@ pub enum FolderEvent {
|
|||||||
#[event(input = "UpdateRecentViewPayloadPB")]
|
#[event(input = "UpdateRecentViewPayloadPB")]
|
||||||
UpdateRecentViews = 37,
|
UpdateRecentViews = 37,
|
||||||
|
|
||||||
#[event()]
|
|
||||||
ReloadWorkspace = 38,
|
|
||||||
|
|
||||||
#[event(input = "GetWorkspaceViewPB", output = "RepeatedViewPB")]
|
#[event(input = "GetWorkspaceViewPB", output = "RepeatedViewPB")]
|
||||||
ReadPrivateViews = 39,
|
ReadPrivateViews = 39,
|
||||||
|
|
||||||
|
@ -80,28 +80,6 @@ impl FolderManager {
|
|||||||
Ok(manager)
|
Ok(manager)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn reload_workspace(&self) -> FlowyResult<()> {
|
|
||||||
let workspace_id = self
|
|
||||||
.workspace_id
|
|
||||||
.read()
|
|
||||||
.as_ref()
|
|
||||||
.ok_or_else(|| {
|
|
||||||
FlowyError::internal().with_context("workspace id is empty when trying to reload workspace")
|
|
||||||
})?
|
|
||||||
.clone();
|
|
||||||
|
|
||||||
let uid = self.user.user_id()?;
|
|
||||||
let doc_state = self
|
|
||||||
.cloud_service
|
|
||||||
.get_folder_doc_state(&workspace_id, uid, CollabType::Folder, &workspace_id)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
self
|
|
||||||
.initialize(uid, &workspace_id, FolderInitDataSource::Cloud(doc_state))
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self), err)]
|
#[instrument(level = "debug", skip(self), err)]
|
||||||
pub async fn get_current_workspace(&self) -> FlowyResult<WorkspacePB> {
|
pub async fn get_current_workspace(&self) -> FlowyResult<WorkspacePB> {
|
||||||
self.with_folder(
|
self.with_folder(
|
||||||
@ -117,7 +95,7 @@ impl FolderManager {
|
|||||||
},
|
},
|
||||||
|folder| {
|
|folder| {
|
||||||
let workspace_pb_from_workspace = |workspace: Workspace, folder: &Folder| {
|
let workspace_pb_from_workspace = |workspace: Workspace, folder: &Folder| {
|
||||||
let views = get_workspace_public_view_pbs(&workspace.id, folder);
|
let views = get_workspace_public_view_pbs(folder);
|
||||||
let workspace: WorkspacePB = (workspace, views).into();
|
let workspace: WorkspacePB = (workspace, views).into();
|
||||||
Ok::<WorkspacePB, FlowyError>(workspace)
|
Ok::<WorkspacePB, FlowyError>(workspace)
|
||||||
};
|
};
|
||||||
@ -139,28 +117,20 @@ impl FolderManager {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|folder| folder.get_workspace_id());
|
.map(|folder| folder.get_workspace_id());
|
||||||
|
|
||||||
if let Some(workspace_id) = workspace_id {
|
if workspace_id.is_some() {
|
||||||
self.get_workspace_public_views(&workspace_id).await
|
self.get_workspace_public_views().await
|
||||||
} else {
|
} else {
|
||||||
tracing::warn!("Can't get the workspace id from the folder. Return empty list.");
|
tracing::warn!("Can't get the workspace id from the folder. Return empty list.");
|
||||||
Ok(vec![])
|
Ok(vec![])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_workspace_public_views(&self, workspace_id: &str) -> FlowyResult<Vec<ViewPB>> {
|
pub async fn get_workspace_public_views(&self) -> FlowyResult<Vec<ViewPB>> {
|
||||||
let views = self.with_folder(Vec::new, |folder| {
|
Ok(self.with_folder(Vec::new, get_workspace_public_view_pbs))
|
||||||
get_workspace_public_view_pbs(workspace_id, folder)
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(views)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_workspace_private_views(&self, workspace_id: &str) -> FlowyResult<Vec<ViewPB>> {
|
pub async fn get_workspace_private_views(&self) -> FlowyResult<Vec<ViewPB>> {
|
||||||
let views = self.with_folder(Vec::new, |folder| {
|
Ok(self.with_folder(Vec::new, get_workspace_private_view_pbs))
|
||||||
get_workspace_private_view_pbs(workspace_id, folder)
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(views)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn make_folder<T: Into<Option<FolderNotify>>>(
|
pub(crate) async fn make_folder<T: Into<Option<FolderNotify>>>(
|
||||||
@ -323,19 +293,6 @@ impl FolderManager {
|
|||||||
Ok(new_workspace)
|
Ok(new_workspace)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "info", skip_all, err)]
|
|
||||||
pub async fn open_workspace(&self, _workspace_id: &str) -> FlowyResult<Workspace> {
|
|
||||||
self.with_folder(
|
|
||||||
|| Err(FlowyError::internal()),
|
|
||||||
|folder| {
|
|
||||||
let workspace = folder.get_current_workspace().ok_or_else(|| {
|
|
||||||
FlowyError::record_not_found().with_context("Can't open not existing workspace")
|
|
||||||
})?;
|
|
||||||
Ok::<Workspace, FlowyError>(workspace)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_workspace(&self, _workspace_id: &str) -> Option<Workspace> {
|
pub async fn get_workspace(&self, _workspace_id: &str) -> Option<Workspace> {
|
||||||
self.with_folder(|| None, |folder| folder.get_current_workspace())
|
self.with_folder(|| None, |folder| folder.get_current_workspace())
|
||||||
}
|
}
|
||||||
@ -1259,7 +1216,7 @@ impl FolderManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the views that belong to the workspace. The views are filtered by the trash and all the private views.
|
/// Return the views that belong to the workspace. The views are filtered by the trash and all the private views.
|
||||||
pub(crate) fn get_workspace_public_view_pbs(_workspace_id: &str, folder: &Folder) -> Vec<ViewPB> {
|
pub(crate) fn get_workspace_public_view_pbs(folder: &Folder) -> Vec<ViewPB> {
|
||||||
// get the trash ids
|
// get the trash ids
|
||||||
let trash_ids = folder
|
let trash_ids = folder
|
||||||
.get_all_trash_sections()
|
.get_all_trash_sections()
|
||||||
@ -1309,7 +1266,7 @@ fn get_all_child_view_ids(folder: &Folder, view_id: &str) -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current private views of the user.
|
/// Get the current private views of the user.
|
||||||
pub(crate) fn get_workspace_private_view_pbs(_workspace_id: &str, folder: &Folder) -> Vec<ViewPB> {
|
pub(crate) fn get_workspace_private_view_pbs(folder: &Folder) -> Vec<ViewPB> {
|
||||||
// get the trash ids
|
// get the trash ids
|
||||||
let trash_ids = folder
|
let trash_ids = folder
|
||||||
.get_all_trash_sections()
|
.get_all_trash_sections()
|
||||||
|
@ -137,7 +137,7 @@ impl FolderManager {
|
|||||||
|
|
||||||
// Index all views in the folder if needed
|
// Index all views in the folder if needed
|
||||||
if !self.folder_indexer.is_indexed() {
|
if !self.folder_indexer.is_indexed() {
|
||||||
let views = folder.get_all_views_recursively();
|
let views = folder.views.get_all_views();
|
||||||
let folder_indexer = self.folder_indexer.clone();
|
let folder_indexer = self.folder_indexer.clone();
|
||||||
|
|
||||||
// We spawn a blocking task to index all views in the folder
|
// We spawn a blocking task to index all views in the folder
|
||||||
|
@ -183,8 +183,8 @@ pub(crate) fn notify_parent_view_did_change<T: AsRef<str>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn notify_did_update_section_views(workspace_id: &str, folder: &Folder) {
|
pub(crate) fn notify_did_update_section_views(workspace_id: &str, folder: &Folder) {
|
||||||
let public_views = get_workspace_public_view_pbs(workspace_id, folder);
|
let public_views = get_workspace_public_view_pbs(folder);
|
||||||
let private_views = get_workspace_private_view_pbs(workspace_id, folder);
|
let private_views = get_workspace_private_view_pbs(folder);
|
||||||
tracing::trace!(
|
tracing::trace!(
|
||||||
"Did update section views: public len = {}, private len = {}",
|
"Did update section views: public len = {}, private len = {}",
|
||||||
public_views.len(),
|
public_views.len(),
|
||||||
@ -210,7 +210,7 @@ pub(crate) fn notify_did_update_section_views(workspace_id: &str, folder: &Folde
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn notify_did_update_workspace(workspace_id: &str, folder: &Folder) {
|
pub(crate) fn notify_did_update_workspace(workspace_id: &str, folder: &Folder) {
|
||||||
let repeated_view: RepeatedViewPB = get_workspace_public_view_pbs(workspace_id, folder).into();
|
let repeated_view: RepeatedViewPB = get_workspace_public_view_pbs(folder).into();
|
||||||
send_notification(workspace_id, FolderNotification::DidUpdateWorkspaceViews)
|
send_notification(workspace_id, FolderNotification::DidUpdateWorkspaceViews)
|
||||||
.payload(repeated_view)
|
.payload(repeated_view)
|
||||||
.send();
|
.send();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use collab::core::collab::IndexContentReceiver;
|
use collab::core::collab::IndexContentReceiver;
|
||||||
use collab_folder::{View, ViewIcon, ViewLayout};
|
use collab_folder::{View, ViewIcon, ViewLayout};
|
||||||
@ -23,5 +24,5 @@ pub trait IndexManager: Send + Sync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait FolderIndexManager: IndexManager {
|
pub trait FolderIndexManager: IndexManager {
|
||||||
fn index_all_views(&self, views: Vec<View>, workspace_id: String);
|
fn index_all_views(&self, views: Vec<Arc<View>>, workspace_id: String);
|
||||||
}
|
}
|
||||||
|
@ -408,14 +408,14 @@ impl IndexManager for FolderIndexManagerImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FolderIndexManager for FolderIndexManagerImpl {
|
impl FolderIndexManager for FolderIndexManagerImpl {
|
||||||
fn index_all_views(&self, views: Vec<View>, workspace_id: String) {
|
fn index_all_views(&self, views: Vec<Arc<View>>, workspace_id: String) {
|
||||||
let indexable_data = views
|
let indexable_data = views
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|view| IndexableData {
|
.map(|view| IndexableData {
|
||||||
id: view.id,
|
id: view.id.clone(),
|
||||||
data: view.name,
|
data: view.name.clone(),
|
||||||
icon: view.icon,
|
icon: view.icon.clone(),
|
||||||
layout: view.layout,
|
layout: view.layout.clone(),
|
||||||
workspace_id: workspace_id.clone(),
|
workspace_id: workspace_id.clone(),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -6,6 +6,7 @@ use serde::de::{MapAccess, Visitor};
|
|||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::fmt::Display;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
@ -15,6 +16,16 @@ pub struct Session {
|
|||||||
pub user_workspace: UserWorkspace,
|
pub user_workspace: UserWorkspace,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for Session {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"user_id: {}, user_workspace: {}:{}",
|
||||||
|
self.user_id, self.user_workspace.name, self.user_workspace.id,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct SessionVisitor;
|
struct SessionVisitor;
|
||||||
impl<'de> Visitor<'de> for SessionVisitor {
|
impl<'de> Visitor<'de> for SessionVisitor {
|
||||||
type Value = Session;
|
type Value = Session;
|
||||||
|
@ -492,7 +492,7 @@ pub async fn get_all_workspace_handler(
|
|||||||
data_result_ok(user_workspaces.into())
|
data_result_ok(user_workspaces.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
#[tracing::instrument(level = "info", skip(data, manager), err)]
|
||||||
pub async fn open_workspace_handler(
|
pub async fn open_workspace_handler(
|
||||||
data: AFPluginData<UserWorkspaceIdPB>,
|
data: AFPluginData<UserWorkspaceIdPB>,
|
||||||
manager: AFPluginState<Weak<UserManager>>,
|
manager: AFPluginState<Weak<UserManager>>,
|
||||||
|
@ -11,7 +11,7 @@ use flowy_user_pub::entities::UserWorkspace;
|
|||||||
use flowy_user_pub::session::Session;
|
use flowy_user_pub::session::Session;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
use tracing::{debug, error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
const SQLITE_VACUUM_042: &str = "sqlite_vacuum_042_version";
|
const SQLITE_VACUUM_042: &str = "sqlite_vacuum_042_version";
|
||||||
|
|
||||||
@ -91,16 +91,17 @@ impl AuthenticateUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_session(&self, session: Option<Session>) -> Result<(), FlowyError> {
|
pub fn set_session(&self, session: Option<Session>) -> Result<(), FlowyError> {
|
||||||
debug!("Set current user session: {:?}", session);
|
|
||||||
match &session {
|
match &session {
|
||||||
None => {
|
None => {
|
||||||
self.session.write().take();
|
let removed_session = self.session.write().take();
|
||||||
|
info!("remove session: {:?}", removed_session);
|
||||||
self
|
self
|
||||||
.store_preferences
|
.store_preferences
|
||||||
.remove(self.user_config.session_cache_key.as_ref());
|
.remove(self.user_config.session_cache_key.as_ref());
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
Some(session) => {
|
Some(session) => {
|
||||||
|
info!("Set current session: {:?}", session);
|
||||||
self.session.write().replace(session.clone());
|
self.session.write().replace(session.clone());
|
||||||
self
|
self
|
||||||
.store_preferences
|
.store_preferences
|
||||||
|
@ -710,7 +710,10 @@ impl UserManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
save_user_workspaces(uid, self.db_connection(uid)?, response.user_workspaces())?;
|
save_user_workspaces(uid, self.db_connection(uid)?, response.user_workspaces())?;
|
||||||
event!(tracing::Level::INFO, "Save new user profile to disk");
|
info!(
|
||||||
|
"Save new user profile to disk, authenticator: {:?}",
|
||||||
|
authenticator
|
||||||
|
);
|
||||||
|
|
||||||
self.authenticate_user.set_session(Some(session.clone()))?;
|
self.authenticate_user.set_session(Some(session.clone()))?;
|
||||||
self
|
self
|
||||||
|
@ -135,6 +135,7 @@ impl UserManager {
|
|||||||
|
|
||||||
#[instrument(skip(self), err)]
|
#[instrument(skip(self), err)]
|
||||||
pub async fn open_workspace(&self, workspace_id: &str) -> FlowyResult<()> {
|
pub async fn open_workspace(&self, workspace_id: &str) -> FlowyResult<()> {
|
||||||
|
info!("open workspace: {}", workspace_id);
|
||||||
let uid = self.user_id()?;
|
let uid = self.user_id()?;
|
||||||
let user_workspace = self
|
let user_workspace = self
|
||||||
.cloud_services
|
.cloud_services
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use chrono::Local;
|
||||||
use std::{fmt, io::Write};
|
use std::{fmt, io::Write};
|
||||||
|
|
||||||
use serde::ser::{SerializeMap, Serializer};
|
use serde::ser::{SerializeMap, Serializer};
|
||||||
@ -45,7 +46,7 @@ where
|
|||||||
) -> Result<(), std::io::Error> {
|
) -> Result<(), std::io::Error> {
|
||||||
map_serializer.serialize_entry(MESSAGE, &message)?;
|
map_serializer.serialize_entry(MESSAGE, &message)?;
|
||||||
// map_serializer.serialize_entry(LEVEL, &format!("{}", level))?;
|
// map_serializer.serialize_entry(LEVEL, &format!("{}", level))?;
|
||||||
// map_serializer.serialize_entry(TIME, &chrono::Utc::now().timestamp())?;
|
map_serializer.serialize_entry(TIME, &Local::now().format("%Y-%m-%d %H:%M:%S").to_string())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,12 +114,9 @@ impl<'a> MakeWriter<'a> for DebugStdoutWriter {
|
|||||||
type Writer = Box<dyn Write>;
|
type Writer = Box<dyn Write>;
|
||||||
|
|
||||||
fn make_writer(&'a self) -> Self::Writer {
|
fn make_writer(&'a self) -> Self::Writer {
|
||||||
#[cfg(not(debug_assertions))]
|
if std::env::var("DISABLE_EVENT_LOG").unwrap_or("false".to_string()) == "true" {
|
||||||
{
|
|
||||||
Box::new(io::sink())
|
Box::new(io::sink())
|
||||||
}
|
} else {
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
{
|
|
||||||
Box::new(io::stdout())
|
Box::new(io::stdout())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user