From 9c01c0dcb5308d8d50ddf2d3fad6599fbff7d3dd Mon Sep 17 00:00:00 2001 From: Alexander Ekdahl Date: Fri, 29 Nov 2019 19:20:48 -0500 Subject: Use env_logger in ra_cli --- crates/ra_cli/Cargo.toml | 7 ++++++- crates/ra_cli/src/main.rs | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index c7e0d0f0f..9718b4b54 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] pico-args = "0.3.0" -flexi_logger = "0.14.0" +log = "0.4" ra_syntax = { path = "../ra_syntax" } ra_ide = { path = "../ra_ide" } @@ -19,3 +19,8 @@ ra_db = { path = "../ra_db" } path = "../ra_prof" # features = [ "cpu_profiler" ] # features = [ "jemalloc" ] + +[dependencies.env_logger] +version = "0.7.1" +default-features = false +features = ["humantime"] diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index fe847e611..3808590ab 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs @@ -7,7 +7,6 @@ mod progress_report; use std::{error::Error, fmt::Write, io::Read}; -use flexi_logger::Logger; use pico_args::Arguments; use ra_ide::{file_structure, Analysis}; use ra_prof::profile; @@ -32,7 +31,7 @@ impl Verbosity { } fn main() -> Result<()> { - Logger::with_env_or_str("error").start()?; + env_logger::try_init()?; let subcommand = match std::env::args_os().nth(1) { None => { -- cgit v1.2.3 From eb4e70fc676a97a7b411f372be1727df51a8906a Mon Sep 17 00:00:00 2001 From: Alexander Ekdahl Date: Fri, 29 Nov 2019 19:35:03 -0500 Subject: Remove flexi_logger from ra_lsp_server --- crates/ra_cli/Cargo.toml | 6 +----- crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/main.rs | 7 +------ crates/ra_lsp_server/tests/heavy_tests/main.rs | 1 - crates/ra_lsp_server/tests/heavy_tests/support.rs | 3 +-- 5 files changed, 4 insertions(+), 15 deletions(-) (limited to 'crates') diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index 9718b4b54..f63f40c99 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml @@ -8,6 +8,7 @@ publish = false [dependencies] pico-args = "0.3.0" log = "0.4" +env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] } ra_syntax = { path = "../ra_syntax" } ra_ide = { path = "../ra_ide" } @@ -19,8 +20,3 @@ ra_db = { path = "../ra_db" } path = "../ra_prof" # features = [ "cpu_profiler" ] # features = [ "jemalloc" ] - -[dependencies.env_logger] -version = "0.7.1" -default-features = false -features = ["humantime"] diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 21aef842c..41672eaff 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -13,7 +13,6 @@ relative-path = "1.0.0" serde_json = "1.0.34" serde = { version = "1.0.83", features = ["derive"] } crossbeam-channel = "0.4" -flexi_logger = "0.14.0" log = "0.4.3" lsp-types = { version = "0.61.0", features = ["proposed"] } rustc-hash = "1.0" @@ -27,6 +26,7 @@ lsp-server = "0.3.0" ra_project_model = { path = "../ra_project_model" } ra_prof = { path = "../ra_prof" } ra_vfs_glob = { path = "../ra_vfs_glob" } +env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] } [dev-dependencies] tempfile = "3" diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index e13c8ca14..8076a7fa5 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -1,6 +1,5 @@ //! `ra_lsp_server` binary -use flexi_logger::{Duplicate, Logger}; use lsp_server::Connection; use ra_lsp_server::{show_message, Result, ServerConfig}; use ra_prof; @@ -14,11 +13,7 @@ fn main() -> Result<()> { fn setup_logging() -> Result<()> { std::env::set_var("RUST_BACKTRACE", "short"); - let logger = Logger::with_env_or_str("error").duplicate_to_stderr(Duplicate::All); - match std::env::var("RA_LOG_DIR") { - Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, - _ => logger.start()?, - }; + env_logger::try_init()?; ra_prof::set_filter(match std::env::var("RA_PROFILE") { Ok(spec) => ra_prof::Filter::from_spec(&spec), diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 2ba82ab05..29224cbe8 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -15,7 +15,6 @@ use tempfile::TempDir; use crate::support::{project, Project}; -const LOG: &'static str = ""; const PROFILE: &'static str = ""; // const PROFILE: &'static str = "*@3>100"; diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 86073b57d..d5ea52fa9 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -7,7 +7,6 @@ use std::{ }; use crossbeam_channel::{after, select, Receiver}; -use flexi_logger::Logger; use lsp_server::{Connection, Message, Notification, Request}; use lsp_types::{ notification::{DidOpenTextDocument, Exit}, @@ -53,7 +52,7 @@ impl<'a> Project<'a> { let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); static INIT: Once = Once::new(); INIT.call_once(|| { - let _ = Logger::with_env_or_str(crate::LOG).start().unwrap(); + let _ = env_logger::builder().is_test(true).try_init().unwrap(); ra_prof::set_filter(if crate::PROFILE.is_empty() { ra_prof::Filter::disabled() } else { -- cgit v1.2.3 From 3fe539ce51f417605a6da6bc3c6d135053b1ee67 Mon Sep 17 00:00:00 2001 From: Alexander Ekdahl Date: Fri, 29 Nov 2019 19:40:59 -0500 Subject: Remove log dependency from ra_cli --- crates/ra_cli/Cargo.toml | 1 - 1 file changed, 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index f63f40c99..21a37c7bf 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml @@ -7,7 +7,6 @@ publish = false [dependencies] pico-args = "0.3.0" -log = "0.4" env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] } ra_syntax = { path = "../ra_syntax" } -- cgit v1.2.3