diff --git a/Cargo.lock b/Cargo.lock index 30ea2934..79ec52f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,6 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -1434,6 +1435,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "getopts" version = "0.2.21" @@ -2194,6 +2205,15 @@ dependencies = [ "libm", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "object" version = "0.36.5" @@ -2413,6 +2433,7 @@ dependencies = [ "tokio", "tracing", "tracing-appender", + "tracing-bunyan-formatter", "tracing-subscriber", "tracing-tree", ] @@ -4012,7 +4033,9 @@ checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -4244,6 +4267,24 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "tracing-bunyan-formatter" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d637245a0d8774bd48df6482e086c59a8b5348a910c3b0579354045a9d82411" +dependencies = [ + "ahash", + "gethostname", + "log", + "serde", + "serde_json", + "time", + "tracing", + "tracing-core", + "tracing-log 0.1.4", + "tracing-subscriber", +] + [[package]] name = "tracing-core" version = "0.1.33" @@ -4254,6 +4295,17 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-log" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + [[package]] name = "tracing-log" version = "0.2.0" @@ -4292,7 +4344,7 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.2.0", "tracing-serde", ] @@ -4303,8 +4355,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f459ca79f1b0d5f71c54ddfde6debfc59c8b6eeb46808ae492077f739dc7b49c" dependencies = [ "nu-ansi-term 0.50.1", + "time", "tracing-core", - "tracing-log", + "tracing-log 0.2.0", "tracing-subscriber", ] diff --git a/Cargo.toml b/Cargo.toml index 7767ef72..e4472250 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,17 +41,18 @@ similar = "2.6.0" smallvec = { version = "1.13.2", features = ["union", "const_new", "serde"] } strum = { version = "0.27.1", features = ["derive"] } # this will use tokio if available, otherwise async-std -sqlx = { version = "0.8.2", features = ["runtime-tokio", "runtime-async-std", "postgres", "json"] } -syn = "1.0.109" -termcolor = "1.4.1" -test-log = "0.2.17" -tokio = { version = "1.40.0", features = ["full"] } -tower-lsp = "0.20.0" -tracing = { version = "0.1.40", default-features = false, features = ["std"] } -tracing-subscriber = "0.3.18" -tree-sitter = "0.20.10" -tree_sitter_sql = { path = "./lib/tree_sitter_sql", version = "0.0.0" } -unicode-width = "0.1.12" +sqlx = { version = "0.8.2", features = ["runtime-tokio", "runtime-async-std", "postgres", "json"] } +syn = "1.0.109" +termcolor = "1.4.1" +test-log = "0.2.17" +tokio = { version = "1.40.0", features = ["full"] } +tower-lsp = "0.20.0" +tracing = { version = "0.1.40", default-features = false, features = ["std"] } +tracing-bunyan-formatter = { version = "0.3.10 " } +tracing-subscriber = "0.3.18" +tree-sitter = "0.20.10" +tree_sitter_sql = { path = "./lib/tree_sitter_sql", version = "0.0.0" } +unicode-width = "0.1.12" # postgres specific crates pgt_analyse = { path = "./crates/pgt_analyse", version = "0.0.0" } diff --git a/crates/pgt_cli/Cargo.toml b/crates/pgt_cli/Cargo.toml index ca61cf65..f2a3fa18 100644 --- a/crates/pgt_cli/Cargo.toml +++ b/crates/pgt_cli/Cargo.toml @@ -37,8 +37,9 @@ serde_json = { workspace = true } tokio = { workspace = true, features = ["io-std", "io-util", "net", "time", "rt", "sync", "rt-multi-thread", "macros"] } tracing = { workspace = true } tracing-appender = "0.2.3" +tracing-bunyan-formatter = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter", "json"] } -tracing-tree = "0.4.0" +tracing-tree = { version = "0.4.0", features = ["time"] } [target.'cfg(unix)'.dependencies] libc = "0.2.161" diff --git a/crates/pgt_cli/src/cli_options.rs b/crates/pgt_cli/src/cli_options.rs index b795c65f..d1bfaee9 100644 --- a/crates/pgt_cli/src/cli_options.rs +++ b/crates/pgt_cli/src/cli_options.rs @@ -61,6 +61,7 @@ pub struct CliOptions { pub reporter: CliReporter, #[bpaf( + env("PGT_LOG_LEVEL"), long("log-level"), argument("none|debug|info|warn|error"), fallback(LoggingLevel::default()), diff --git a/crates/pgt_cli/src/commands/daemon.rs b/crates/pgt_cli/src/commands/daemon.rs index 0f6c4aac..988286f4 100644 --- a/crates/pgt_cli/src/commands/daemon.rs +++ b/crates/pgt_cli/src/commands/daemon.rs @@ -11,13 +11,13 @@ use tokio::runtime::Runtime; use tracing::subscriber::Interest; use tracing::{Instrument, Metadata, debug_span, metadata::LevelFilter}; use tracing_appender::rolling::Rotation; +use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; use tracing_subscriber::{ - Layer, layer::{Context, Filter}, prelude::*, registry, }; -use tracing_tree::HierarchicalLayer; +use tracing_tree::{HierarchicalLayer, time::UtcDateTime}; pub(crate) fn start( session: CliSession, @@ -78,8 +78,10 @@ pub(crate) fn run_server( config_path: Option, log_path: Option, log_file_name_prefix: Option, + log_level: Option, + log_kind: Option, ) -> Result<(), CliDiagnostic> { - setup_tracing_subscriber(log_path, log_file_name_prefix); + setup_tracing_subscriber(log_path, log_file_name_prefix, log_level, log_kind); let rt = Runtime::new()?; let factory = ServerFactory::new(stop_on_disconnect); @@ -181,9 +183,16 @@ async fn start_lsp_proxy( /// is written to log files rotated on a hourly basis (in /// `pgt-logs/server.log.yyyy-MM-dd-HH` files inside the system temporary /// directory) -fn setup_tracing_subscriber(log_path: Option, log_file_name_prefix: Option) { +fn setup_tracing_subscriber( + log_path: Option, + log_file_name_prefix: Option, + log_level: Option, + log_kind: Option, +) { let pgt_log_path = log_path.unwrap_or(pgt_fs::ensure_cache_dir().join("pgt-logs")); + let appender_builder = tracing_appender::rolling::RollingFileAppender::builder(); + let file_appender = appender_builder .filename_prefix(log_file_name_prefix.unwrap_or(String::from("server.log"))) .max_log_files(7) @@ -191,18 +200,37 @@ fn setup_tracing_subscriber(log_path: Option, log_file_name_prefix: Opt .build(pgt_log_path) .expect("Failed to start the logger for the daemon."); - registry() - .with( - HierarchicalLayer::default() - .with_indent_lines(true) - .with_indent_amount(2) - .with_bracketed_fields(true) - .with_targets(true) - .with_ansi(false) - .with_writer(file_appender) - .with_filter(LoggingFilter), - ) - .init(); + let filter = PgtLoggingFilter::from(log_level); + + let log_kind = log_kind.unwrap_or("hierarchical".into()); + + match log_kind.as_str() { + "bunyan" => { + registry() + .with(JsonStorageLayer) + .with( + BunyanFormattingLayer::new("pgt_logs".into(), file_appender) + .with_filter(filter), + ) + .init(); + } + + _ => registry() + .with( + HierarchicalLayer::default() + .with_indent_lines(true) + .with_indent_amount(2) + .with_bracketed_fields(true) + .with_targets(true) + .with_ansi(false) + .with_timer(UtcDateTime { + higher_precision: false, + }) + .with_writer(file_appender) + .with_filter(filter), + ) + .init(), + } } pub fn default_pgt_log_path() -> PathBuf { @@ -212,22 +240,34 @@ pub fn default_pgt_log_path() -> PathBuf { } } -/// Tracing filter enabling: -/// - All spans and events at level info or higher -/// - All spans and events at level debug in crates whose name starts with `pgt` -struct LoggingFilter; +/// Tracing Filter with two rules: +/// For all crates starting with pgt*, use `PGT_LOG_LEVEL` or CLI option or "info" as default +/// For all other crates, use "info" +struct PgtLoggingFilter(LevelFilter); -/// Tracing filter used for spans emitted by `pgt*` crates -const SELF_FILTER: LevelFilter = if cfg!(debug_assertions) { - LevelFilter::TRACE -} else { - LevelFilter::DEBUG -}; +impl From> for PgtLoggingFilter { + fn from(value: Option) -> Self { + Self( + value + .map(|lv_filter| match lv_filter.as_str() { + "trace" => LevelFilter::TRACE, + "debug" => LevelFilter::DEBUG, + "info" => LevelFilter::INFO, + "warn" => LevelFilter::WARN, + "error" => LevelFilter::ERROR, + "off" => LevelFilter::OFF, + + _ => LevelFilter::INFO, + }) + .unwrap_or(LevelFilter::INFO), + ) + } +} -impl LoggingFilter { +impl PgtLoggingFilter { fn is_enabled(&self, meta: &Metadata<'_>) -> bool { let filter = if meta.target().starts_with("pgt") { - SELF_FILTER + self.0 } else { LevelFilter::INFO }; @@ -236,7 +276,7 @@ impl LoggingFilter { } } -impl Filter for LoggingFilter { +impl Filter for PgtLoggingFilter { fn enabled(&self, meta: &Metadata<'_>, _cx: &Context<'_, S>) -> bool { self.is_enabled(meta) } @@ -250,6 +290,6 @@ impl Filter for LoggingFilter { } fn max_level_hint(&self) -> Option { - Some(SELF_FILTER) + Some(self.0) } } diff --git a/crates/pgt_cli/src/commands/mod.rs b/crates/pgt_cli/src/commands/mod.rs index 49b74766..b166a033 100644 --- a/crates/pgt_cli/src/commands/mod.rs +++ b/crates/pgt_cli/src/commands/mod.rs @@ -151,6 +151,7 @@ pub enum PgtCommand { display_fallback )] log_prefix_name: String, + /// Allows to change the folder where logs are stored. #[bpaf( env("PGT_LOG_PATH"), @@ -161,6 +162,24 @@ pub enum PgtCommand { )] log_path: PathBuf, + /// Allows to change the log level. Default is debug. This will only affect "pgt*" crates. All others are logged with info level. + #[bpaf( + env("PGT_LOG_LEVEL"), + long("log-level"), + argument("trace|debug|info|warn|error|none"), + fallback(String::from("debug")) + )] + log_level: String, + + /// Allows to change the logging format kind. Default is hierarchical. + #[bpaf( + env("PGT_LOG_KIND"), + long("log-kind"), + argument("hierarchical|bunyan"), + fallback(String::from("hierarchical")) + )] + log_kind: String, + #[bpaf(long("stop-on-disconnect"), hide_usage)] stop_on_disconnect: bool, /// Allows to set a custom file path to the configuration file, diff --git a/crates/pgt_cli/src/lib.rs b/crates/pgt_cli/src/lib.rs index 4197f181..f8a04244 100644 --- a/crates/pgt_cli/src/lib.rs +++ b/crates/pgt_cli/src/lib.rs @@ -105,11 +105,15 @@ impl<'app> CliSession<'app> { config_path, log_path, log_prefix_name, + log_level, + log_kind, } => commands::daemon::run_server( stop_on_disconnect, config_path, Some(log_path), Some(log_prefix_name), + Some(log_level), + Some(log_kind), ), PgtCommand::PrintSocket => commands::daemon::print_socket(), }; diff --git a/crates/pgt_cli/src/logging.rs b/crates/pgt_cli/src/logging.rs index e9086655..35911927 100644 --- a/crates/pgt_cli/src/logging.rs +++ b/crates/pgt_cli/src/logging.rs @@ -11,6 +11,7 @@ pub fn setup_cli_subscriber(level: LoggingLevel, kind: LoggingKind) { if level == LoggingLevel::None { return; } + let format = tracing_subscriber::fmt::layer() .with_level(true) .with_target(false) diff --git a/crates/pgt_lsp/src/handlers/completions.rs b/crates/pgt_lsp/src/handlers/completions.rs index e60029fc..f18ae598 100644 --- a/crates/pgt_lsp/src/handlers/completions.rs +++ b/crates/pgt_lsp/src/handlers/completions.rs @@ -3,7 +3,11 @@ use anyhow::Result; use pgt_workspace::{WorkspaceError, features::completions::GetCompletionsParams}; use tower_lsp::lsp_types::{self, CompletionItem, CompletionItemLabelDetails}; -#[tracing::instrument(level = "trace", skip_all)] +#[tracing::instrument(level = "debug", skip_all, fields( + url = params.text_document_position.text_document.uri.as_str(), + character = params.text_document_position.position.character, + line = params.text_document_position.position.line +), err)] pub fn get_completions( session: &Session, params: lsp_types::CompletionParams, diff --git a/crates/pgt_lsp/src/handlers/text_document.rs b/crates/pgt_lsp/src/handlers/text_document.rs index 63250ef5..d36b8a32 100644 --- a/crates/pgt_lsp/src/handlers/text_document.rs +++ b/crates/pgt_lsp/src/handlers/text_document.rs @@ -10,7 +10,10 @@ use tower_lsp::lsp_types; use tracing::error; /// Handler for `textDocument/didOpen` LSP notification -#[tracing::instrument(level = "debug", skip(session), err)] +#[tracing::instrument(level = "info", skip_all, fields( + url = params.text_document.uri.as_str(), + version = params.text_document.version +), err)] pub(crate) async fn did_open( session: &Session, params: lsp_types::DidOpenTextDocumentParams, @@ -38,7 +41,11 @@ pub(crate) async fn did_open( } // Handler for `textDocument/didChange` LSP notification -#[tracing::instrument(level = "debug", skip(session), err)] +#[tracing::instrument(level = "debug", skip_all, fields( + uri = params.text_document.uri.as_str(), + version = params.text_document.version, + num_content_changes = params.content_changes.len() +), err)] pub(crate) async fn did_change( session: &Session, params: lsp_types::DidChangeTextDocumentParams, @@ -90,7 +97,9 @@ pub(crate) async fn did_change( } /// Handler for `textDocument/didClose` LSP notification -#[tracing::instrument(level = "debug", skip(session), err)] +#[tracing::instrument(level = "info", skip_all, fields( + url = params.text_document.uri.as_str(), +), err)] pub(crate) async fn did_close( session: &Session, params: lsp_types::DidCloseTextDocumentParams, diff --git a/crates/pgt_lsp/src/server.rs b/crates/pgt_lsp/src/server.rs index d4f801f2..9bf9b9c2 100644 --- a/crates/pgt_lsp/src/server.rs +++ b/crates/pgt_lsp/src/server.rs @@ -152,14 +152,13 @@ impl LanguageServer for LSPServer { } #[tracing::instrument(level = "info", skip_all)] - async fn did_change_configuration(&self, params: DidChangeConfigurationParams) { - let _ = params; + async fn did_change_configuration(&self, _params: DidChangeConfigurationParams) { self.session.load_workspace_settings().await; self.setup_capabilities().await; self.session.update_all_diagnostics().await; } - #[tracing::instrument(level = "trace", skip(self))] + #[tracing::instrument(level = "trace", skip_all)] async fn did_change_watched_files(&self, params: DidChangeWatchedFilesParams) { let file_paths = params .changes @@ -195,28 +194,28 @@ impl LanguageServer for LSPServer { } } - #[tracing::instrument(level = "trace", skip(self))] + #[tracing::instrument(level = "trace", skip_all)] async fn did_open(&self, params: DidOpenTextDocumentParams) { handlers::text_document::did_open(&self.session, params) .await .ok(); } - #[tracing::instrument(level = "trace", skip(self, params))] + #[tracing::instrument(level = "trace", skip_all)] async fn did_change(&self, params: DidChangeTextDocumentParams) { if let Err(e) = handlers::text_document::did_change(&self.session, params).await { error!("{}", e); }; } - #[tracing::instrument(level = "trace", skip(self))] + #[tracing::instrument(level = "trace", skip_all)] async fn did_close(&self, params: DidCloseTextDocumentParams) { handlers::text_document::did_close(&self.session, params) .await .ok(); } - #[tracing::instrument(level = "trace", skip(self))] + #[tracing::instrument(level = "trace", skip_all)] async fn completion(&self, params: CompletionParams) -> LspResult> { match handlers::completions::get_completions(&self.session, params) { Ok(result) => LspResult::Ok(Some(result)), @@ -228,7 +227,7 @@ impl LanguageServer for LSPServer { async fn code_action(&self, params: CodeActionParams) -> LspResult> { match handlers::code_actions::get_actions(&self.session, params) { Ok(result) => { - tracing::info!("Got Code Actions: {:?}", result); + tracing::trace!("Got {} Code Action(s)", result.len()); return LspResult::Ok(Some(result)); } Err(e) => LspResult::Err(into_lsp_error(e)), diff --git a/crates/pgt_text_size/src/size.rs b/crates/pgt_text_size/src/size.rs index e35e1c24..1082485e 100644 --- a/crates/pgt_text_size/src/size.rs +++ b/crates/pgt_text_size/src/size.rs @@ -2,7 +2,8 @@ use { crate::TextLen, std::{ convert::TryFrom, - fmt, iter, + fmt::{self, Display}, + iter, num::TryFromIntError, ops::{Add, AddAssign, Sub, SubAssign}, }, @@ -31,6 +32,12 @@ impl fmt::Debug for TextSize { } } +impl Display for TextSize { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.raw) + } +} + impl TextSize { /// Creates a new instance of `TextSize` from a raw `u32`. #[inline] diff --git a/crates/pgt_workspace/src/settings.rs b/crates/pgt_workspace/src/settings.rs index 29f05098..2e7d8f53 100644 --- a/crates/pgt_workspace/src/settings.rs +++ b/crates/pgt_workspace/src/settings.rs @@ -78,7 +78,7 @@ impl AsMut for SettingsHandleMut<'_> { impl Settings { /// The [PartialConfiguration] is merged into the workspace - #[tracing::instrument(level = "trace", skip(self))] + #[tracing::instrument(level = "trace", skip(self), err)] pub fn merge_with_configuration( &mut self, configuration: PartialConfiguration, diff --git a/crates/pgt_workspace/src/workspace/server.rs b/crates/pgt_workspace/src/workspace/server.rs index adbd72a6..032b92c6 100644 --- a/crates/pgt_workspace/src/workspace/server.rs +++ b/crates/pgt_workspace/src/workspace/server.rs @@ -153,7 +153,7 @@ impl Workspace for WorkspaceServer { /// ## Panics /// This function may panic if the internal settings mutex has been poisoned /// by another thread having previously panicked while holding the lock - #[tracing::instrument(level = "trace", skip(self))] + #[tracing::instrument(level = "trace", skip(self), err)] fn update_settings(&self, params: UpdateSettingsParams) -> Result<(), WorkspaceError> { tracing::info!("Updating settings in workspace"); @@ -179,10 +179,8 @@ impl Workspace for WorkspaceServer { } /// Add a new file to the workspace - #[tracing::instrument(level = "trace", skip(self))] + #[tracing::instrument(level = "info", skip_all, fields(path = params.path.as_path().as_os_str().to_str()), err)] fn open_file(&self, params: OpenFileParams) -> Result<(), WorkspaceError> { - tracing::info!("Opening file: {:?}", params.path); - let doc = Document::new(params.path.clone(), params.content, params.version); doc.iter_statements_with_text().for_each(|(stmt, content)| { @@ -211,6 +209,10 @@ impl Workspace for WorkspaceServer { } /// Change the content of an open file + #[tracing::instrument(level = "debug", skip_all, fields( + path = params.path.as_os_str().to_str(), + version = params.version + ), err)] fn change_file(&self, params: super::ChangeFileParams) -> Result<(), WorkspaceError> { let mut doc = self .documents @@ -221,22 +223,39 @@ impl Workspace for WorkspaceServer { params.version, )); - tracing::info!("Changing file: {:?}", params); - for c in &doc.apply_file_change(¶ms) { match c { StatementChange::Added(added) => { - tracing::debug!("Adding statement: {:?}", added); + tracing::debug!( + "Adding statement: id:{:?}, path:{:?}, text:{:?}", + added.stmt.id, + added.stmt.path.as_os_str().to_str(), + added.text + ); self.tree_sitter.add_statement(&added.stmt, &added.text); self.pg_query.add_statement(&added.stmt, &added.text); } StatementChange::Deleted(s) => { - tracing::debug!("Deleting statement: {:?}", s); + tracing::debug!( + "Deleting statement: id:{:?}, path:{:?}", + s.id, + s.path.as_os_str() + ); self.tree_sitter.remove_statement(s); self.pg_query.remove_statement(s); } StatementChange::Modified(s) => { - tracing::debug!("Modifying statement: {:?}", s); + tracing::debug!( + "Modifying statement with id {:?} (new id {:?}) in {:?}. Range {:?}, Changed from '{:?}' to '{:?}', changed text: {:?}", + s.old_stmt.id, + s.new_stmt.id, + s.old_stmt.path.as_os_str().to_str(), + s.change_range, + s.old_stmt_text, + s.new_stmt_text, + s.change_text + ); + self.tree_sitter.modify_statement(s); self.pg_query.modify_statement(s); } @@ -498,17 +517,14 @@ impl Workspace for WorkspaceServer { }) } - #[tracing::instrument(level = "debug", skip(self))] + #[tracing::instrument(level = "debug", skip_all, fields( + path = params.path.as_os_str().to_str(), + position = params.position.to_string() + ), err)] fn get_completions( &self, params: GetCompletionsParams, ) -> Result { - tracing::debug!( - "Getting completions for file {:?} at position {:?}", - ¶ms.path, - ¶ms.position - ); - let pool = match self.connection.read().unwrap().get_pool() { Some(pool) => pool, None => return Ok(CompletionsResult::default()), @@ -519,12 +535,6 @@ impl Workspace for WorkspaceServer { .get(¶ms.path) .ok_or(WorkspaceError::not_found())?; - tracing::debug!( - "Found the document. Looking for statement in file {:?} at position: {:?}", - ¶ms.path, - ¶ms.position - ); - let (statement, stmt_range, text) = match doc .iter_statements_with_text_and_range() .find(|(_, r, _)| r.contains(params.position)) @@ -540,7 +550,7 @@ impl Workspace for WorkspaceServer { let tree = self.tree_sitter.get_parse_tree(&statement); tracing::debug!( - "Found the statement. We're looking for position {:?}. Statement Range {:?} to {:?}. Statement: {}", + "Found the statement. We're looking for position {:?}. Statement Range {:?} to {:?}. Statement: {:?}", position, stmt_range.start(), stmt_range.end(), @@ -549,8 +559,6 @@ impl Workspace for WorkspaceServer { let schema_cache = self.schema_cache.load(pool)?; - tracing::debug!("Loaded schema cache for completions"); - let items = pgt_completions::complete(pgt_completions::CompletionParams { position, schema: schema_cache.as_ref(), diff --git a/crates/pgt_workspace/src/workspace/server/pg_query.rs b/crates/pgt_workspace/src/workspace/server/pg_query.rs index 48f7cf13..3ed452fc 100644 --- a/crates/pgt_workspace/src/workspace/server/pg_query.rs +++ b/crates/pgt_workspace/src/workspace/server/pg_query.rs @@ -28,7 +28,7 @@ impl PgQueryStore { if let Ok(ast) = r { self.ast_db.insert(statement.clone(), Arc::new(ast)); } else { - tracing::info!("adding diagnostics"); + tracing::info!("invalid statement, adding diagnostics."); self.diagnostics .insert(statement.clone(), SyntaxDiagnostic::from(r.unwrap_err())); } diff --git a/justfile b/justfile index 69c59dae..3e7163b3 100644 --- a/justfile +++ b/justfile @@ -109,5 +109,8 @@ merge-main: # Make sure to set your PGT_LOG_PATH in your shell profile. +# You can use the PGT_LOG_LEVEL to set your log level. +# We recommend to install `bunyan` (npm i -g bunyan) and pipe the output through there for color-coding: +# just show-logs | bunyan show-logs: tail -f $(ls $PGT_LOG_PATH/server.log.* | sort -t- -k2,2 -k3,3 -k4,4 | tail -n 1)