diff --git a/Cargo.lock b/Cargo.lock index 25e257fa993..e725efaf354 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -577,13 +577,15 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-test-plugin", "cairo-lang-utils", - "log", "salsa", "scarb-metadata", "serde", "serde_json", "tokio", "tower-lsp", + "tracing", + "tracing-log", + "tracing-subscriber", ] [[package]] @@ -1625,7 +1627,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata", + "regex-automata 0.4.3", "regex-syntax 0.8.2", ] @@ -1742,7 +1744,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata", + "regex-automata 0.4.3", "same-file", "walkdir", "winapi-util", @@ -1980,6 +1982,15 @@ dependencies = [ "url", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matrixmultiply" version = "0.2.4" @@ -2542,10 +2553,19 @@ checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata", + "regex-automata 0.4.3", "regex-syntax 0.8.2", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + [[package]] name = "regex-automata" version = "0.4.3" @@ -2557,6 +2577,12 @@ dependencies = [ "regex-syntax 0.8.2", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.7.5" @@ -2834,6 +2860,15 @@ dependencies = [ "keccak", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "sierra-compile" version = "2.5.3" @@ -3214,6 +3249,16 @@ dependencies = [ "thiserror-impl-no-std", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.31" @@ -3447,6 +3492,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -3521,6 +3596,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" diff --git a/crates/cairo-lang-language-server/Cargo.toml b/crates/cairo-lang-language-server/Cargo.toml index 2c12df9a936..cc8fc89d9cd 100644 --- a/crates/cairo-lang-language-server/Cargo.toml +++ b/crates/cairo-lang-language-server/Cargo.toml @@ -20,13 +20,15 @@ cairo-lang-semantic = { path = "../cairo-lang-semantic", version = "2.5.3" } cairo-lang-starknet = { path = "../cairo-lang-starknet", version = "2.5.3" } cairo-lang-syntax = { path = "../cairo-lang-syntax", version = "2.5.3" } cairo-lang-test-plugin = { path = "../cairo-lang-test-plugin", version = "2.5.3" } -cairo-lang-utils = { path = "../cairo-lang-utils", version = "2.5.3", features = ["env_logger"] } -log.workspace = true +cairo-lang-utils = { path = "../cairo-lang-utils", version = "2.5.3" } salsa.workspace = true scarb-metadata = "1" serde = { workspace = true, default-features = true } serde_json.workspace = true tokio = { version = "1.33.0", features = ["full"] } tower-lsp = "0.20.0" +tracing = "0.1" +tracing-log = "0.2" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } [dev-dependencies] diff --git a/crates/cairo-lang-language-server/src/lib.rs b/crates/cairo-lang-language-server/src/lib.rs index 419af155f4a..cab870904fd 100644 --- a/crates/cairo-lang-language-server/src/lib.rs +++ b/crates/cairo-lang-language-server/src/lib.rs @@ -52,11 +52,9 @@ use cairo_lang_syntax::node::kind::SyntaxKind; use cairo_lang_syntax::node::utils::is_grandparent_of_kind; use cairo_lang_syntax::node::{ast, SyntaxNode, TypedSyntaxNode}; use cairo_lang_test_plugin::test_plugin_suite; -use cairo_lang_utils::logging::init_logging; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use cairo_lang_utils::ordered_hash_set::OrderedHashSet; use cairo_lang_utils::{try_extract_matches, OptionHelper, Upcast}; -use log::warn; use salsa::InternKey; use semantic_highlighting::token_kind::SemanticTokenKind; use semantic_highlighting::SemanticTokensTraverser; @@ -66,6 +64,8 @@ use tower_lsp::jsonrpc::{Error as LSPError, Result as LSPResult}; use tower_lsp::lsp_types::notification::Notification; use tower_lsp::lsp_types::*; use tower_lsp::{Client, LanguageServer, LspService, Server}; +use tracing::warn; +use tracing_subscriber::filter::{EnvFilter, LevelFilter}; use vfs::{ProvideVirtualFileRequest, ProvideVirtualFileResponse}; use crate::completions::{colon_colon_completions, dot_completions, generic_completions}; @@ -82,7 +82,16 @@ const DEFAULT_CAIRO_LSP_DB_REPLACE_INTERVAL: u64 = 300; #[tokio::main] pub async fn start() { - init_logging(log::LevelFilter::Warn); + tracing_subscriber::fmt() + .with_writer(std::io::stderr) + .with_env_filter( + EnvFilter::builder() + .with_default_directive(LevelFilter::WARN.into()) + .with_env_var("CAIRO_LS_LOG") + .from_env_lossy(), + ) + .with_ansi(false) + .init(); let (stdin, stdout) = (tokio::io::stdin(), tokio::io::stdout());