Skip to content

Commit

Permalink
LS: Use tracing instead of log
Browse files Browse the repository at this point in the history
commit-id:f5e463c0
  • Loading branch information
mkaput committed Feb 6, 2024
1 parent bcf990e commit ec9242e
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 9 deletions.
89 changes: 85 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crates/cairo-lang-language-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
15 changes: 12 additions & 3 deletions crates/cairo-lang-language-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand All @@ -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());

Expand Down

0 comments on commit ec9242e

Please sign in to comment.