mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: support pg storage (#2935)
* refactor: using tokio-postgres * chore: update * chore: update env * chore: update * chore: upgrade supabase and add logout button * refactor: update * chore: update * refactor: using message queue to handle the pg connection * refactor: move test * refactor: update sql * chore: create pg database when user login * chore: update scheme * chore: generic user service * chore: update * chore: create statistics * chore: create snapshot * chore: add test * chore: add database cloud service * chore: add document cloud service * chore: update interface * test: add document test * refactor: document interface * chore: fix test * chore: update * chore: update test * test: add test * test: add test * test: add test * chore: update collab rev * fix: flutter analyzer * chore: update * chore: update * chore: update * fix: tests * chore: update * chore: update collab rev * ci: rust fmt --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
use std::{fmt, io::Write};
|
||||
|
||||
use serde::ser::{SerializeMap, Serializer};
|
||||
use serde_json::Value;
|
||||
use std::{fmt, io::Write};
|
||||
use tracing::{Event, Id, Subscriber};
|
||||
use tracing_bunyan_formatter::JsonStorage;
|
||||
use tracing_core::{metadata::Level, span::Attributes};
|
||||
|
||||
use tracing_subscriber::{fmt::MakeWriter, layer::Context, registry::SpanRef, Layer};
|
||||
|
||||
const LEVEL: &str = "level";
|
||||
const TIME: &str = "time";
|
||||
const MESSAGE: &str = "msg";
|
||||
@ -22,6 +23,7 @@ pub struct FlowyFormattingLayer<W: MakeWriter + 'static> {
|
||||
}
|
||||
|
||||
impl<W: MakeWriter + 'static> FlowyFormattingLayer<W> {
|
||||
#[allow(dead_code)]
|
||||
pub fn new(make_writer: W) -> Self {
|
||||
Self {
|
||||
make_writer,
|
||||
|
@ -1,14 +1,13 @@
|
||||
mod layer;
|
||||
use crate::layer::*;
|
||||
use std::sync::RwLock;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use log::LevelFilter;
|
||||
use std::sync::RwLock;
|
||||
use tracing::subscriber::set_global_default;
|
||||
use tracing_appender::{non_blocking::WorkerGuard, rolling::RollingFileAppender};
|
||||
use tracing_bunyan_formatter::JsonStorageLayer;
|
||||
use tracing_log::LogTracer;
|
||||
use tracing_subscriber::{layer::SubscriberExt, EnvFilter};
|
||||
|
||||
mod layer;
|
||||
lazy_static! {
|
||||
static ref LOG_GUARD: RwLock<Option<WorkerGuard>> = RwLock::new(None);
|
||||
}
|
||||
@ -40,22 +39,22 @@ impl Builder {
|
||||
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 (_non_blocking, guard) = tracing_appender::non_blocking(self.file_appender);
|
||||
let subscriber = tracing_subscriber::fmt()
|
||||
.with_ansi(true)
|
||||
.with_target(false)
|
||||
.with_target(true)
|
||||
.with_max_level(tracing::Level::TRACE)
|
||||
.with_writer(std::io::stderr)
|
||||
.with_thread_ids(true)
|
||||
.json()
|
||||
// .with_current_span(true)
|
||||
// .with_span_list(true)
|
||||
.with_current_span(true)
|
||||
.with_span_list(true)
|
||||
.compact()
|
||||
.finish()
|
||||
.with(env_filter)
|
||||
.with(JsonStorageLayer)
|
||||
.with(FlowyFormattingLayer::new(std::io::stdout))
|
||||
.with(FlowyFormattingLayer::new(non_blocking));
|
||||
.with(env_filter);
|
||||
// .with(JsonStorageLayer)
|
||||
// .with(FlowyFormattingLayer::new(std::io::stdout))
|
||||
// .with(FlowyFormattingLayer::new(non_blocking));
|
||||
|
||||
set_global_default(subscriber).map_err(|e| format!("{:?}", e))?;
|
||||
LogTracer::builder()
|
||||
@ -71,6 +70,7 @@ impl Builder {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// run cargo test --features="use_bunyan" or cargo test
|
||||
#[test]
|
||||
fn test_log() {
|
||||
|
Reference in New Issue
Block a user