Skip to content

Commit

Permalink
only use env_logger in binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
tdelabro committed May 30, 2023
1 parent 4e0cf74 commit 9b308a6
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 16 deletions.
4 changes: 4 additions & 0 deletions crates/cairo-lang-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ thiserror.workspace = true
[dev-dependencies]
test-log.workspace = true

[features]
env_logger = ["cairo-lang-utils/env_logger"]

[[bin]]
name = "cairo-compile"
path = "src/cli.rs"
required-features = ["env_logger"]
13 changes: 8 additions & 5 deletions crates/cairo-lang-formatter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ repository.workspace = true
license-file.workspace = true
description = "Cairo formatter."

[[bin]]
name = "cairo-format"
path = "src/bin/cli.rs"

[dependencies]
anyhow.workspace = true
cairo-lang-diagnostics = { path = "../cairo-lang-diagnostics", version = "1.1.0" }
Expand All @@ -27,7 +23,14 @@ salsa.workspace = true
smol_str.workspace = true

[dev-dependencies]
cairo-lang-utils = { path = "../cairo-lang-utils", version = "1.1.0" }
pretty_assertions.workspace = true
test-case.workspace = true
test-log.workspace = true

[features]
env_logger = ["cairo-lang-utils/env_logger"]

[[bin]]
name = "cairo-format"
path = "src/bin/cli.rs"
required-features = ["env_logger"]
12 changes: 8 additions & 4 deletions crates/cairo-lang-language-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ repository.workspace = true
license-file.workspace = true
description = "Cairo language server."

[[bin]]
name = "cairo-language-server"
path = "src/bin/language_server.rs"

[dependencies]
anyhow.workspace = true
cairo-lang-compiler = { path = "../cairo-lang-compiler", version = "1.1.0" }
Expand Down Expand Up @@ -39,3 +35,11 @@ tower-lsp.workspace = true

[dev-dependencies]
test-log.workspace = true

[features]
env_logger = ["cairo-lang-utils/env_logger"]

[[bin]]
name = "cairo-language-server"
path = "src/bin/language_server.rs"
required-features = ["env_logger"]
2 changes: 2 additions & 0 deletions crates/cairo-lang-language-server/src/bin/language_server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use cairo_lang_language_server::serve_language_service;
use cairo_lang_utils::logging::init_logging;

#[tokio::main]
async fn main() {
init_logging(log::LevelFilter::Warn);
serve_language_service().await;
}
3 changes: 0 additions & 3 deletions crates/cairo-lang-language-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use cairo_lang_syntax::node::kind::SyntaxKind;
use cairo_lang_syntax::node::stable_ptr::SyntaxStablePtr;
use cairo_lang_syntax::node::utils::is_grandparent_of_kind;
use cairo_lang_syntax::node::{ast, SyntaxNode, TypedSyntaxNode};
use cairo_lang_utils::logging::init_logging;
use cairo_lang_utils::ordered_hash_set::OrderedHashSet;
use cairo_lang_utils::{try_extract_matches, OptionHelper, Upcast};
use log::warn;
Expand All @@ -69,8 +68,6 @@ pub mod vfs;
const MAX_CRATE_DETECTION_DEPTH: usize = 20;

pub async fn serve_language_service() {
init_logging(log::LevelFilter::Warn);

#[cfg(feature = "runtime-agnostic")]
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};

Expand Down
8 changes: 5 additions & 3 deletions crates/cairo-lang-sierra-to-casm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ repository.workspace = true
license-file.workspace = true
description = "Emitting of CASM instructions from Sierra code."

[features]
testing = []

[dependencies]
anyhow.workspace = true
assert_matches.workspace = true
Expand All @@ -33,6 +30,11 @@ pretty_assertions.workspace = true
test-case.workspace = true
test-log.workspace = true

[features]
testing = []
env_logger = ["cairo-lang-utils/env_logger"]

[[bin]]
name = "sierra-compile"
path = "src/cli.rs"
required-features = ["env_logger"]
4 changes: 4 additions & 0 deletions crates/cairo-lang-syntax-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ xshell.workspace = true
env_logger.workspace = true
test-log.workspace = true

[features]
env_logger = ["cairo-lang-utils/env_logger"]

[[bin]]
name = "generate-syntax"
path = "src/generate_syntax.rs"
required-features = ["env_logger"]
3 changes: 2 additions & 1 deletion crates/cairo-lang-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ description = "General utilities for the Cairo compiler project."
testing = []

[dependencies]
env_logger.workspace = true
indexmap.workspace = true
itertools.workspace = true
log.workspace = true
Expand All @@ -19,8 +18,10 @@ num-integer.workspace = true
num-traits.workspace = true
serde.workspace = true
time.workspace = true
env_logger = { workspace = true, optional = true }

[dev-dependencies]
serde_json.workspace = true
test-case.workspace = true
test-log.workspace = true
env_logger.workspace = true
1 change: 1 addition & 0 deletions crates/cairo-lang-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod collection_arithmetics;
pub mod extract_matches;
pub mod graph_algos;
pub mod iterators;
#[cfg(feature = "env_logger")]
pub mod logging;
pub mod ordered_hash_map;
pub mod ordered_hash_set;
Expand Down

0 comments on commit 9b308a6

Please sign in to comment.