switch log crate to tracing

This commit is contained in:
Dezhi Wu 2021-08-15 20:46:13 +08:00
parent d15f646ff1
commit ba0947dded
48 changed files with 277 additions and 239 deletions

35
Cargo.lock generated
View file

@ -324,15 +324,6 @@ dependencies = [
"log", "log",
] ]
[[package]]
name = "env_logger"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"log",
]
[[package]] [[package]]
name = "expect-test" name = "expect-test"
version = "1.1.0" version = "1.1.0"
@ -380,12 +371,12 @@ dependencies = [
"cargo_metadata", "cargo_metadata",
"crossbeam-channel", "crossbeam-channel",
"jod-thread", "jod-thread",
"log",
"paths", "paths",
"serde", "serde",
"serde_json", "serde_json",
"stdx", "stdx",
"toolchain", "toolchain",
"tracing",
] ]
[[package]] [[package]]
@ -462,7 +453,6 @@ dependencies = [
"hir_ty", "hir_ty",
"indexmap", "indexmap",
"itertools", "itertools",
"log",
"once_cell", "once_cell",
"profile", "profile",
"rustc-hash", "rustc-hash",
@ -490,7 +480,6 @@ dependencies = [
"itertools", "itertools",
"la-arena", "la-arena",
"limit", "limit",
"log",
"mbe", "mbe",
"once_cell", "once_cell",
"profile", "profile",
@ -499,6 +488,7 @@ dependencies = [
"stdx", "stdx",
"syntax", "syntax",
"test_utils", "test_utils",
"tracing",
"tt", "tt",
] ]
@ -514,13 +504,13 @@ dependencies = [
"itertools", "itertools",
"la-arena", "la-arena",
"limit", "limit",
"log",
"mbe", "mbe",
"parser", "parser",
"profile", "profile",
"rustc-hash", "rustc-hash",
"syntax", "syntax",
"test_utils", "test_utils",
"tracing",
"tt", "tt",
] ]
@ -541,7 +531,6 @@ dependencies = [
"itertools", "itertools",
"la-arena", "la-arena",
"limit", "limit",
"log",
"once_cell", "once_cell",
"profile", "profile",
"rustc-hash", "rustc-hash",
@ -581,7 +570,6 @@ dependencies = [
"ide_ssr", "ide_ssr",
"indexmap", "indexmap",
"itertools", "itertools",
"log",
"oorandom", "oorandom",
"profile", "profile",
"pulldown-cmark", "pulldown-cmark",
@ -591,6 +579,7 @@ dependencies = [
"syntax", "syntax",
"test_utils", "test_utils",
"text_edit", "text_edit",
"tracing",
"url", "url",
] ]
@ -625,7 +614,6 @@ dependencies = [
"hir", "hir",
"ide_db", "ide_db",
"itertools", "itertools",
"log",
"once_cell", "once_cell",
"profile", "profile",
"rustc-hash", "rustc-hash",
@ -634,6 +622,7 @@ dependencies = [
"syntax", "syntax",
"test_utils", "test_utils",
"text_edit", "text_edit",
"tracing",
"xshell", "xshell",
] ]
@ -649,7 +638,6 @@ dependencies = [
"hir", "hir",
"itertools", "itertools",
"limit", "limit",
"log",
"once_cell", "once_cell",
"profile", "profile",
"rayon", "rayon",
@ -658,6 +646,7 @@ dependencies = [
"syntax", "syntax",
"test_utils", "test_utils",
"text_edit", "text_edit",
"tracing",
] ]
[[package]] [[package]]
@ -889,7 +878,6 @@ version = "0.0.0"
dependencies = [ dependencies = [
"cov-mark", "cov-mark",
"expect-test", "expect-test",
"log",
"parser", "parser",
"profile", "profile",
"rustc-hash", "rustc-hash",
@ -897,6 +885,7 @@ dependencies = [
"stdx", "stdx",
"syntax", "syntax",
"test_utils", "test_utils",
"tracing",
"tt", "tt",
] ]
@ -1121,7 +1110,6 @@ version = "0.0.0"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"jod-thread", "jod-thread",
"log",
"memmap2", "memmap2",
"object", "object",
"paths", "paths",
@ -1130,6 +1118,7 @@ dependencies = [
"serde_json", "serde_json",
"snap", "snap",
"stdx", "stdx",
"tracing",
"tt", "tt",
] ]
@ -1188,7 +1177,6 @@ dependencies = [
"cfg", "cfg",
"expect-test", "expect-test",
"la-arena", "la-arena",
"log",
"paths", "paths",
"profile", "profile",
"rustc-hash", "rustc-hash",
@ -1197,6 +1185,7 @@ dependencies = [
"serde_json", "serde_json",
"stdx", "stdx",
"toolchain", "toolchain",
"tracing",
] ]
[[package]] [[package]]
@ -1308,7 +1297,6 @@ dependencies = [
"cfg", "cfg",
"crossbeam-channel", "crossbeam-channel",
"dissimilar", "dissimilar",
"env_logger",
"expect-test", "expect-test",
"flycheck", "flycheck",
"hir", "hir",
@ -1319,7 +1307,6 @@ dependencies = [
"ide_ssr", "ide_ssr",
"itertools", "itertools",
"jod-thread", "jod-thread",
"log",
"lsp-server", "lsp-server",
"lsp-types", "lsp-types",
"mbe", "mbe",
@ -1343,6 +1330,7 @@ dependencies = [
"tikv-jemallocator", "tikv-jemallocator",
"toolchain", "toolchain",
"tracing", "tracing",
"tracing-log",
"tracing-subscriber", "tracing-subscriber",
"tracing-tree", "tracing-tree",
"tt", "tt",
@ -1737,6 +1725,7 @@ dependencies = [
"thread_local", "thread_local",
"tracing", "tracing",
"tracing-core", "tracing-core",
"tracing-log",
] ]
[[package]] [[package]]
@ -1838,10 +1827,10 @@ version = "0.0.0"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"jod-thread", "jod-thread",
"log",
"notify", "notify",
"paths", "paths",
"rustc-hash", "rustc-hash",
"tracing",
"vfs", "vfs",
"walkdir", "walkdir",
] ]

View file

@ -10,7 +10,7 @@ doctest = false
[dependencies] [dependencies]
crossbeam-channel = "0.5.0" crossbeam-channel = "0.5.0"
log = "0.4.8" tracing = "0.1"
cargo_metadata = "0.14" cargo_metadata = "0.14"
serde = { version = "1.0.106", features = ["derive"] } serde = { version = "1.0.106", features = ["derive"] }
serde_json = "1.0.48" serde_json = "1.0.48"

View file

@ -163,7 +163,7 @@ impl FlycheckActor {
self.cancel_check_process(); self.cancel_check_process();
let mut command = self.check_command(); let mut command = self.check_command();
log::info!("restart flycheck {:?}", command); tracing::info!("restart flycheck {:?}", command);
command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null()); command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null());
if let Ok(child) = command.spawn().map(JodChild) { if let Ok(child) = command.spawn().map(JodChild) {
self.cargo_handle = Some(CargoHandle::spawn(child)); self.cargo_handle = Some(CargoHandle::spawn(child));
@ -176,7 +176,7 @@ impl FlycheckActor {
let cargo_handle = self.cargo_handle.take().unwrap(); let cargo_handle = self.cargo_handle.take().unwrap();
let res = cargo_handle.join(); let res = cargo_handle.join();
if res.is_err() { if res.is_err() {
log::error!( tracing::error!(
"Flycheck failed to run the following command: {:?}", "Flycheck failed to run the following command: {:?}",
self.check_command() self.check_command()
) )
@ -319,7 +319,7 @@ impl CargoActor {
let message = match message { let message = match message {
Ok(message) => message, Ok(message) => message,
Err(err) => { Err(err) => {
log::error!("Invalid json from cargo check, ignoring ({})", err); tracing::error!("Invalid json from cargo check, ignoring ({})", err);
continue; continue;
} }
}; };

View file

@ -9,7 +9,6 @@ edition = "2018"
doctest = false doctest = false
[dependencies] [dependencies]
log = "0.4.8"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
either = "1.5.3" either = "1.5.3"
arrayvec = "0.7" arrayvec = "0.7"

View file

@ -11,7 +11,7 @@ doctest = false
[dependencies] [dependencies]
cov-mark = "2.0.0-pre.1" cov-mark = "2.0.0-pre.1"
dashmap = { version = "4.0.2", features = ["raw-api"] } dashmap = { version = "4.0.2", features = ["raw-api"] }
log = "0.4.8" tracing = "0.1"
once_cell = "1.3.1" once_cell = "1.3.1"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
either = "1.5.3" either = "1.5.3"

View file

@ -135,7 +135,7 @@ impl Expander {
None => { None => {
// Only `None` if the macro expansion produced no usable AST. // Only `None` if the macro expansion produced no usable AST.
if err.is_none() { if err.is_none() {
log::warn!("no error despite `parse_or_expand` failing"); tracing::warn!("no error despite `parse_or_expand` failing");
} }
return Ok(ExpandResult::only_err(err.unwrap_or_else(|| { return Ok(ExpandResult::only_err(err.unwrap_or_else(|| {
@ -152,7 +152,7 @@ impl Expander {
} }
}; };
log::debug!("macro expansion {:#?}", node.syntax()); tracing::debug!("macro expansion {:#?}", node.syntax());
self.recursion_limit += 1; self.recursion_limit += 1;
let mark = Mark { let mark = Mark {

View file

@ -64,7 +64,7 @@ pub(super) fn collect_defs(
if block.is_none() { if block.is_none() {
// populate external prelude // populate external prelude
for dep in &crate_graph[def_map.krate].dependencies { for dep in &crate_graph[def_map.krate].dependencies {
log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); tracing::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id);
let dep_def_map = db.crate_def_map(dep.crate_id); let dep_def_map = db.crate_def_map(dep.crate_id);
def_map def_map
.extern_prelude .extern_prelude
@ -358,7 +358,7 @@ impl DefCollector<'_> {
i += 1; i += 1;
if FIXED_POINT_LIMIT.check(i).is_err() { if FIXED_POINT_LIMIT.check(i).is_err() {
log::error!("name resolution is stuck"); tracing::error!("name resolution is stuck");
break 'outer; break 'outer;
} }
} }
@ -510,7 +510,7 @@ impl DefCollector<'_> {
return; return;
} }
_ => { _ => {
log::debug!( tracing::debug!(
"could not resolve prelude path `{}` to module (resolved to {:?})", "could not resolve prelude path `{}` to module (resolved to {:?})",
path, path,
per_ns.types per_ns.types
@ -654,7 +654,7 @@ impl DefCollector<'_> {
current_module_id: LocalModuleId, current_module_id: LocalModuleId,
extern_crate: &item_tree::ExternCrate, extern_crate: &item_tree::ExternCrate,
) { ) {
log::debug!( tracing::debug!(
"importing macros from extern crate: {:?} ({:?})", "importing macros from extern crate: {:?} ({:?})",
extern_crate, extern_crate,
self.def_map.edition, self.def_map.edition,
@ -718,7 +718,7 @@ impl DefCollector<'_> {
} }
fn resolve_import(&self, module_id: LocalModuleId, import: &Import) -> PartialResolvedImport { fn resolve_import(&self, module_id: LocalModuleId, import: &Import) -> PartialResolvedImport {
log::debug!("resolving import: {:?} ({:?})", import, self.def_map.edition); tracing::debug!("resolving import: {:?} ({:?})", import, self.def_map.edition);
if import.is_extern_crate { if import.is_extern_crate {
let res = self.def_map.resolve_name_in_extern_prelude( let res = self.def_map.resolve_name_in_extern_prelude(
self.db, self.db,
@ -794,7 +794,7 @@ impl DefCollector<'_> {
def.macros = None; def.macros = None;
} }
log::debug!("resolved import {:?} ({:?}) to {:?}", name, import, def); tracing::debug!("resolved import {:?} ({:?}) to {:?}", name, import, def);
// extern crates in the crate root are special-cased to insert entries into the extern prelude: rust-lang/rust#54658 // extern crates in the crate root are special-cased to insert entries into the extern prelude: rust-lang/rust#54658
if import.is_extern_crate && module_id == self.def_map.root { if import.is_extern_crate && module_id == self.def_map.root {
@ -806,7 +806,7 @@ impl DefCollector<'_> {
self.update(module_id, &[(name, def)], vis, ImportType::Named); self.update(module_id, &[(name, def)], vis, ImportType::Named);
} }
ImportKind::Glob => { ImportKind::Glob => {
log::debug!("glob import: {:?}", import); tracing::debug!("glob import: {:?}", import);
match def.take_types() { match def.take_types() {
Some(ModuleDefId::ModuleId(m)) => { Some(ModuleDefId::ModuleId(m)) => {
if import.is_prelude { if import.is_prelude {
@ -895,10 +895,10 @@ impl DefCollector<'_> {
self.update(module_id, &resolutions, vis, ImportType::Glob); self.update(module_id, &resolutions, vis, ImportType::Glob);
} }
Some(d) => { Some(d) => {
log::debug!("glob import {:?} from non-module/enum {:?}", import, d); tracing::debug!("glob import {:?} from non-module/enum {:?}", import, d);
} }
None => { None => {
log::debug!("glob import {:?} didn't resolve as type", import); tracing::debug!("glob import {:?} didn't resolve as type", import);
} }
} }
} }
@ -947,7 +947,7 @@ impl DefCollector<'_> {
let tr = match res.take_types() { let tr = match res.take_types() {
Some(ModuleDefId::TraitId(tr)) => tr, Some(ModuleDefId::TraitId(tr)) => tr,
Some(other) => { Some(other) => {
log::debug!("non-trait `_` import of {:?}", other); tracing::debug!("non-trait `_` import of {:?}", other);
continue; continue;
} }
None => continue, None => continue,
@ -1167,7 +1167,7 @@ impl DefCollector<'_> {
) { ) {
if EXPANSION_DEPTH_LIMIT.check(depth).is_err() { if EXPANSION_DEPTH_LIMIT.check(depth).is_err() {
cov_mark::hit!(macro_expansion_overflow); cov_mark::hit!(macro_expansion_overflow);
log::warn!("macro expansion is too deep"); tracing::warn!("macro expansion is too deep");
return; return;
} }
let file_id = macro_call_id.as_file(); let file_id = macro_call_id.as_file();
@ -1694,7 +1694,7 @@ impl ModCollector<'_, '_> {
} else if self.is_builtin_or_registered_attr(&attr.path) { } else if self.is_builtin_or_registered_attr(&attr.path) {
continue; continue;
} else { } else {
log::debug!("non-builtin attribute {}", attr.path); tracing::debug!("non-builtin attribute {}", attr.path);
let ast_id = AstIdWithPath::new( let ast_id = AstIdWithPath::new(
self.file_id(), self.file_id(),
@ -1768,7 +1768,7 @@ impl ModCollector<'_, '_> {
} }
None => { None => {
// FIXME: diagnose // FIXME: diagnose
log::debug!("malformed derive: {:?}", attr); tracing::debug!("malformed derive: {:?}", attr);
} }
} }
} }

View file

@ -27,7 +27,7 @@ impl ModDir {
fn child(&self, dir_path: DirPath, root_non_dir_owner: bool) -> Option<ModDir> { fn child(&self, dir_path: DirPath, root_non_dir_owner: bool) -> Option<ModDir> {
let depth = self.depth + 1; let depth = self.depth + 1;
if MOD_DEPTH_LIMIT.check(depth as usize).is_err() { if MOD_DEPTH_LIMIT.check(depth as usize).is_err() {
log::error!("MOD_DEPTH_LIMIT exceeded"); tracing::error!("MOD_DEPTH_LIMIT exceeded");
cov_mark::hit!(circular_mods); cov_mark::hit!(circular_mods);
return None; return None;
} }

View file

@ -116,7 +116,7 @@ impl DefMap {
if self.block_id() != m.block { if self.block_id() != m.block {
cov_mark::hit!(adjust_vis_in_block_def_map); cov_mark::hit!(adjust_vis_in_block_def_map);
vis = Visibility::Module(self.module_id(self.root())); vis = Visibility::Module(self.module_id(self.root()));
log::debug!("visibility {:?} points outside DefMap, adjusting to {:?}", m, vis); tracing::debug!("visibility {:?} points outside DefMap, adjusting to {:?}", m, vis);
} }
} }
@ -204,7 +204,7 @@ impl DefMap {
Some((idx, segment)) => (idx, segment), Some((idx, segment)) => (idx, segment),
None => return ResolvePathResult::empty(ReachedFixedPoint::Yes), None => return ResolvePathResult::empty(ReachedFixedPoint::Yes),
}; };
log::debug!("resolving {:?} in crate root (+ extern prelude)", segment); tracing::debug!("resolving {:?} in crate root (+ extern prelude)", segment);
self.resolve_name_in_crate_root_or_extern_prelude(db, segment) self.resolve_name_in_crate_root_or_extern_prelude(db, segment)
} }
PathKind::Plain => { PathKind::Plain => {
@ -221,7 +221,7 @@ impl DefMap {
let prefer_module = let prefer_module =
if path.segments().len() == 1 { shadow } else { BuiltinShadowMode::Module }; if path.segments().len() == 1 { shadow } else { BuiltinShadowMode::Module };
log::debug!("resolving {:?} in module", segment); tracing::debug!("resolving {:?} in module", segment);
self.resolve_name_in_module(db, original_module, segment, prefer_module) self.resolve_name_in_module(db, original_module, segment, prefer_module)
} }
PathKind::Super(lvl) => { PathKind::Super(lvl) => {
@ -236,7 +236,11 @@ impl DefMap {
PathKind::Super(lvl - i), PathKind::Super(lvl - i),
path.segments().to_vec(), path.segments().to_vec(),
); );
log::debug!("`super` path: {} -> {} in parent map", path, new_path); tracing::debug!(
"`super` path: {} -> {} in parent map",
path,
new_path
);
return block.parent.def_map(db).resolve_path_fp_with_macro( return block.parent.def_map(db).resolve_path_fp_with_macro(
db, db,
mode, mode,
@ -246,7 +250,7 @@ impl DefMap {
); );
} }
None => { None => {
log::debug!("super path in root module"); tracing::debug!("super path in root module");
return ResolvePathResult::empty(ReachedFixedPoint::Yes); return ResolvePathResult::empty(ReachedFixedPoint::Yes);
} }
}, },
@ -270,7 +274,7 @@ impl DefMap {
None => return ResolvePathResult::empty(ReachedFixedPoint::Yes), None => return ResolvePathResult::empty(ReachedFixedPoint::Yes),
}; };
if let Some(def) = self.extern_prelude.get(segment) { if let Some(def) = self.extern_prelude.get(segment) {
log::debug!("absolute path {:?} resolved to crate {:?}", path, def); tracing::debug!("absolute path {:?} resolved to crate {:?}", path, def);
PerNs::types(*def, Visibility::Public) PerNs::types(*def, Visibility::Public)
} else { } else {
return ResolvePathResult::empty(ReachedFixedPoint::No); // extern crate declarations can add to the extern prelude return ResolvePathResult::empty(ReachedFixedPoint::No); // extern crate declarations can add to the extern prelude
@ -299,7 +303,7 @@ impl DefMap {
PathKind::Super(0), PathKind::Super(0),
path.segments()[i..].iter().cloned(), path.segments()[i..].iter().cloned(),
); );
log::debug!("resolving {:?} in other crate", path); tracing::debug!("resolving {:?} in other crate", path);
let defp_map = module.def_map(db); let defp_map = module.def_map(db);
let (def, s) = defp_map.resolve_path(db, module.local_id, &path, shadow); let (def, s) = defp_map.resolve_path(db, module.local_id, &path, shadow);
return ResolvePathResult::with( return ResolvePathResult::with(
@ -351,7 +355,7 @@ impl DefMap {
s => { s => {
// could be an inherent method call in UFCS form // could be an inherent method call in UFCS form
// (`Struct::method`), or some other kind of associated item // (`Struct::method`), or some other kind of associated item
log::debug!( tracing::debug!(
"path segment {:?} resolved to non-module {:?}, but is not last", "path segment {:?} resolved to non-module {:?}, but is not last",
segment, segment,
curr, curr,

View file

@ -70,7 +70,7 @@ impl Attrs {
} }
_ => { _ => {
log::trace!("malformed `#[proc_macro_derive]`: {}", derive); tracing::trace!("malformed `#[proc_macro_derive]`: {}", derive);
None None
} }
} }

View file

@ -10,7 +10,7 @@ doctest = false
[dependencies] [dependencies]
cov-mark = "2.0.0-pre.1" cov-mark = "2.0.0-pre.1"
log = "0.4.8" tracing = "0.1"
either = "1.5.3" either = "1.5.3"
rustc-hash = "1.0.0" rustc-hash = "1.0.0"
la-arena = { version = "0.2.0", path = "../../lib/arena" } la-arena = { version = "0.2.0", path = "../../lib/arena" }

View file

@ -1,6 +1,6 @@
//! Builtin derives. //! Builtin derives.
use log::debug; use tracing::debug;
use mbe::ExpandResult; use mbe::ExpandResult;
use parser::FragmentKind; use parser::FragmentKind;

View file

@ -203,7 +203,7 @@ fn parse_macro_expansion(
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join("\n"); .join("\n");
log::warn!( tracing::warn!(
"fail on macro_parse: (reason: {:?} macro_call: {:#}) parents: {}", "fail on macro_parse: (reason: {:?} macro_call: {:#}) parents: {}",
err, err,
node.value, node.value,
@ -217,13 +217,13 @@ fn parse_macro_expansion(
let fragment_kind = macro_fragment_kind(db, macro_file.macro_call_id); let fragment_kind = macro_fragment_kind(db, macro_file.macro_call_id);
log::debug!("expanded = {}", tt.as_debug_string()); tracing::debug!("expanded = {}", tt.as_debug_string());
log::debug!("kind = {:?}", fragment_kind); tracing::debug!("kind = {:?}", fragment_kind);
let (parse, rev_token_map) = match mbe::token_tree_to_syntax_node(&tt, fragment_kind) { let (parse, rev_token_map) = match mbe::token_tree_to_syntax_node(&tt, fragment_kind) {
Ok(it) => it, Ok(it) => it,
Err(err) => { Err(err) => {
log::debug!( tracing::debug!(
"failed to parse expansion to {:?} = {}", "failed to parse expansion to {:?} = {}",
fragment_kind, fragment_kind,
tt.as_debug_string() tt.as_debug_string()
@ -250,7 +250,7 @@ fn parse_macro_expansion(
} }
} }
None => { None => {
log::debug!("parse = {:?}", parse.syntax_node().kind()); tracing::debug!("parse = {:?}", parse.syntax_node().kind());
ExpandResult { value: Some((parse, Arc::new(rev_token_map))), err: None } ExpandResult { value: Some((parse, Arc::new(rev_token_map))), err: None }
} }
} }
@ -321,7 +321,7 @@ fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<TokenExpander>>
Ok(it) => it, Ok(it) => it,
Err(err) => { Err(err) => {
let name = macro_rules.name().map(|n| n.to_string()).unwrap_or_default(); let name = macro_rules.name().map(|n| n.to_string()).unwrap_or_default();
log::warn!("fail on macro_def parse ({}): {:?} {:#?}", name, err, tt); tracing::warn!("fail on macro_def parse ({}): {:?} {:#?}", name, err, tt);
return None; return None;
} }
}; };
@ -334,7 +334,7 @@ fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<TokenExpander>>
Ok(it) => it, Ok(it) => it,
Err(err) => { Err(err) => {
let name = macro_def.name().map(|n| n.to_string()).unwrap_or_default(); let name = macro_def.name().map(|n| n.to_string()).unwrap_or_default();
log::warn!("fail on macro_def parse ({}): {:?} {:#?}", name, err, tt); tracing::warn!("fail on macro_def parse ({}): {:?} {:#?}", name, err, tt);
return None; return None;
} }
}; };

View file

@ -561,7 +561,7 @@ impl<'a> InFile<&'a SyntaxNode> {
Some(range) => { Some(range) => {
let original_file = range.file_id.original_file(db); let original_file = range.file_id.original_file(db);
if range.file_id != original_file.into() { if range.file_id != original_file.into() {
log::error!("Failed mapping up more for {:?}", range); tracing::error!("Failed mapping up more for {:?}", range);
} }
Some(FileRange { file_id: original_file, range: range.value }) Some(FileRange { file_id: original_file, range: range.value })
} }

View file

@ -14,7 +14,7 @@ itertools = "0.10.0"
arrayvec = "0.7" arrayvec = "0.7"
smallvec = "1.2.0" smallvec = "1.2.0"
ena = "0.14.0" ena = "0.14.0"
log = "0.4.8" tracing = "0.1"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
scoped-tls = "1" scoped-tls = "1"
chalk-solve = { version = "0.70", default-features = false } chalk-solve = { version = "0.70", default-features = false }

View file

@ -10,7 +10,7 @@ use chalk_ir::{cast::Cast, fold::Fold, interner::HasInterner, VariableKind};
use hir_def::lang_item::LangItemTarget; use hir_def::lang_item::LangItemTarget;
use hir_expand::name::name; use hir_expand::name::name;
use limit::Limit; use limit::Limit;
use log::{info, warn}; use tracing::{info, warn};
use crate::{ use crate::{
db::HirDatabase, static_lifetime, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds, db::HirDatabase, static_lifetime, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds,

View file

@ -3,7 +3,7 @@
use std::sync::Arc; use std::sync::Arc;
use cov_mark::hit; use cov_mark::hit;
use log::debug; use tracing::debug;
use chalk_ir::{cast::Cast, fold::shift::Shift, CanonicalVarKinds}; use chalk_ir::{cast::Cast, fold::shift::Shift, CanonicalVarKinds};
use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait}; use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait};

View file

@ -28,7 +28,10 @@ impl ConstExt for Const {
chalk_ir::ConstValue::Concrete(..) => false, chalk_ir::ConstValue::Concrete(..) => false,
_ => { _ => {
log::error!("is_unknown was called on a non-concrete constant value! {:?}", self); tracing::error!(
"is_unknown was called on a non-concrete constant value! {:?}",
self
);
true true
} }
} }

View file

@ -81,7 +81,7 @@ pub(crate) fn trait_solve_query(
GoalData::DomainGoal(DomainGoal::Holds(WhereClause::AliasEq(_))) => "alias_eq".to_string(), GoalData::DomainGoal(DomainGoal::Holds(WhereClause::AliasEq(_))) => "alias_eq".to_string(),
_ => "??".to_string(), _ => "??".to_string(),
}); });
log::info!("trait_solve_query({:?})", goal.value.goal); tracing::info!("trait_solve_query({:?})", goal.value.goal);
if let GoalData::DomainGoal(DomainGoal::Holds(WhereClause::AliasEq(AliasEq { if let GoalData::DomainGoal(DomainGoal::Holds(WhereClause::AliasEq(AliasEq {
alias: AliasTy::Projection(projection_ty), alias: AliasTy::Projection(projection_ty),
@ -106,7 +106,7 @@ fn solve(
goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<Interner>>>, goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<Interner>>>,
) -> Option<chalk_solve::Solution<Interner>> { ) -> Option<chalk_solve::Solution<Interner>> {
let context = ChalkContext { db, krate }; let context = ChalkContext { db, krate };
log::debug!("solve goal: {:?}", goal); tracing::debug!("solve goal: {:?}", goal);
let mut solver = create_chalk_solver(); let mut solver = create_chalk_solver();
let fuel = std::cell::Cell::new(CHALK_SOLVER_FUEL); let fuel = std::cell::Cell::new(CHALK_SOLVER_FUEL);
@ -116,7 +116,7 @@ fn solve(
let remaining = fuel.get(); let remaining = fuel.get();
fuel.set(remaining - 1); fuel.set(remaining - 1);
if remaining == 0 { if remaining == 0 {
log::debug!("fuel exhausted"); tracing::debug!("fuel exhausted");
} }
remaining > 0 remaining > 0
}; };
@ -136,7 +136,7 @@ fn solve(
solver.solve_limited(&context, goal, &should_continue) solver.solve_limited(&context, goal, &should_continue)
}; };
log::debug!("solve({:?}) => {:?}", goal, solution); tracing::debug!("solve({:?}) => {:?}", goal, solution);
solution solution
}; };

View file

@ -13,7 +13,7 @@ cov-mark = "2.0.0-pre.1"
either = "1.5.3" either = "1.5.3"
indexmap = "1.4.0" indexmap = "1.4.0"
itertools = "0.10.0" itertools = "0.10.0"
log = "0.4.8" tracing = "0.1"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
oorandom = "11.1.2" oorandom = "11.1.2"
pulldown-cmark-to-cmark = "6.0.0" pulldown-cmark-to-cmark = "6.0.0"

View file

@ -353,7 +353,7 @@ impl TryToNav for hir::MacroDef {
Either::Left(it) => it, Either::Left(it) => it,
Either::Right(it) => it, Either::Right(it) => it,
}; };
log::debug!("nav target {:#?}", name_owner.syntax()); tracing::debug!("nav target {:#?}", name_owner.syntax());
let mut res = NavigationTarget::from_named( let mut res = NavigationTarget::from_named(
db, db,
src.as_ref().with_value(name_owner), src.as_ref().with_value(name_owner),

View file

@ -11,7 +11,7 @@ doctest = false
[dependencies] [dependencies]
cov-mark = "2.0.0-pre.1" cov-mark = "2.0.0-pre.1"
itertools = "0.10.0" itertools = "0.10.0"
log = "0.4.8" tracing = "0.1"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
either = "1.6.1" either = "1.6.1"
once_cell = "1.7" once_cell = "1.7"

View file

@ -10,7 +10,7 @@ doctest = false
[dependencies] [dependencies]
cov-mark = "2.0.0-pre.1" cov-mark = "2.0.0-pre.1"
log = "0.4.8" tracing = "0.1"
rayon = "1.5.0" rayon = "1.5.0"
fst = { version = "0.4", default-features = false } fst = { version = "0.4", default-features = false }
rustc-hash = "1.1.0" rustc-hash = "1.1.0"

View file

@ -20,7 +20,7 @@ impl RootDatabase {
pub fn apply_change(&mut self, change: Change) { pub fn apply_change(&mut self, change: Change) {
let _p = profile::span("RootDatabase::apply_change"); let _p = profile::span("RootDatabase::apply_change");
self.request_cancellation(); self.request_cancellation();
log::info!("apply_change {:?}", change); tracing::info!("apply_change {:?}", change);
if let Some(roots) = &change.roots { if let Some(roots) = &change.roots {
let mut local_roots = FxHashSet::default(); let mut local_roots = FxHashSet::default();
let mut library_roots = FxHashSet::default(); let mut library_roots = FxHashSet::default();

View file

@ -12,8 +12,8 @@ doctest = false
cov-mark = "2.0.0-pre.1" cov-mark = "2.0.0-pre.1"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
smallvec = "1.2.0" smallvec = "1.2.0"
log = "0.4.8"
expect-test = "1.1" expect-test = "1.1"
tracing = "0.1"
syntax = { path = "../syntax", version = "0.0.0" } syntax = { path = "../syntax", version = "0.0.0" }
parser = { path = "../parser", version = "0.0.0" } parser = { path = "../parser", version = "0.0.0" }

View file

@ -174,7 +174,11 @@ fn expand_repeat(
counter += 1; counter += 1;
if counter == limit { if counter == limit {
log::warn!("expand_tt in repeat pattern exceed limit => {:#?}\n{:#?}", template, ctx); tracing::warn!(
"expand_tt in repeat pattern exceed limit => {:#?}\n{:#?}",
template,
ctx
);
return ExpandResult { return ExpandResult {
value: Fragment::Tokens(Subtree::default().into()), value: Fragment::Tokens(Subtree::default().into()),
err: Some(ExpandError::Other("Expand exceed limit".to_string())), err: Some(ExpandError::Other("Expand exceed limit".to_string())),

View file

@ -11,7 +11,7 @@ doctest = false
[dependencies] [dependencies]
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["unbounded_depth"] } serde_json = { version = "1.0", features = ["unbounded_depth"] }
log = "0.4.8" tracing = "0.1"
crossbeam-channel = "0.5.0" crossbeam-channel = "0.5.0"
jod-thread = "0.1.1" jod-thread = "0.1.1"
memmap2 = "0.3.0" memmap2 = "0.3.0"

View file

@ -93,7 +93,7 @@ fn read_json<'a>(
// Some ill behaved macro try to use stdout for debugging // Some ill behaved macro try to use stdout for debugging
// We ignore it here // We ignore it here
if !buf.starts_with('{') { if !buf.starts_with('{') {
log::error!("proc-macro tried to print : {}", buf); tracing::error!("proc-macro tried to print : {}", buf);
continue; continue;
} }
@ -102,7 +102,7 @@ fn read_json<'a>(
} }
fn write_json(out: &mut impl Write, msg: &str) -> io::Result<()> { fn write_json(out: &mut impl Write, msg: &str) -> io::Result<()> {
log::debug!("> {}", msg); tracing::debug!("> {}", msg);
out.write_all(msg.as_bytes())?; out.write_all(msg.as_bytes())?;
out.write_all(b"\n")?; out.write_all(b"\n")?;
out.flush()?; out.flush()?;

View file

@ -54,7 +54,7 @@ impl ProcMacroProcessSrv {
Ok(res) => res, Ok(res) => res,
Err(err) => { Err(err) => {
let result = self.process.child.try_wait(); let result = self.process.child.try_wait();
log::error!( tracing::error!(
"proc macro server crashed, server process state: {:?}, server request error: {:?}", "proc macro server crashed, server process state: {:?}, server request error: {:?}",
result, result,
err err

View file

@ -9,7 +9,7 @@ edition = "2018"
doctest = false doctest = false
[dependencies] [dependencies]
log = "0.4.8" tracing = "0.1"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
cargo_metadata = "0.14" cargo_metadata = "0.14"
semver = "1" semver = "1"

View file

@ -283,7 +283,7 @@ impl CargoWorkspace {
let meta = from_value::<PackageMetadata>(metadata.clone()).unwrap_or_default(); let meta = from_value::<PackageMetadata>(metadata.clone()).unwrap_or_default();
let is_member = ws_members.contains(id); let is_member = ws_members.contains(id);
let edition = edition.parse::<Edition>().unwrap_or_else(|err| { let edition = edition.parse::<Edition>().unwrap_or_else(|err| {
log::error!("Failed to parse edition {}", err); tracing::error!("Failed to parse edition {}", err);
Edition::CURRENT Edition::CURRENT
}); });
@ -322,7 +322,7 @@ impl CargoWorkspace {
// https://github.com/rust-lang/cargo/issues/7841 // https://github.com/rust-lang/cargo/issues/7841
// is fixed and hits stable (around 1.43-is probably?). // is fixed and hits stable (around 1.43-is probably?).
None => { None => {
log::error!("Node id do not match in cargo metadata, ignoring {}", node.id); tracing::error!("Node id do not match in cargo metadata, ignoring {}", node.id);
continue; continue;
} }
}; };
@ -335,7 +335,7 @@ impl CargoWorkspace {
let pkg = match pkg_by_id.get(&dep_node.pkg) { let pkg = match pkg_by_id.get(&dep_node.pkg) {
Some(&pkg) => pkg, Some(&pkg) => pkg,
None => { None => {
log::error!( tracing::error!(
"Dep node id do not match in cargo metadata, ignoring {}", "Dep node id do not match in cargo metadata, ignoring {}",
dep_node.pkg dep_node.pkg
); );
@ -385,7 +385,7 @@ impl CargoWorkspace {
fn rustc_discover_host_triple(cargo_toml: &ManifestPath) -> Option<String> { fn rustc_discover_host_triple(cargo_toml: &ManifestPath) -> Option<String> {
let mut rustc = Command::new(toolchain::rustc()); let mut rustc = Command::new(toolchain::rustc());
rustc.current_dir(cargo_toml.parent()).arg("-vV"); rustc.current_dir(cargo_toml.parent()).arg("-vV");
log::debug!("Discovering host platform by {:?}", rustc); tracing::debug!("Discovering host platform by {:?}", rustc);
match utf8_stdout(rustc) { match utf8_stdout(rustc) {
Ok(stdout) => { Ok(stdout) => {
let field = "host: "; let field = "host: ";
@ -394,12 +394,12 @@ fn rustc_discover_host_triple(cargo_toml: &ManifestPath) -> Option<String> {
Some(target.to_string()) Some(target.to_string())
} else { } else {
// If we fail to resolve the host platform, it's not the end of the world. // If we fail to resolve the host platform, it's not the end of the world.
log::info!("rustc -vV did not report host platform, got:\n{}", stdout); tracing::info!("rustc -vV did not report host platform, got:\n{}", stdout);
None None
} }
} }
Err(e) => { Err(e) => {
log::warn!("Failed to discover host platform: {}", e); tracing::warn!("Failed to discover host platform: {}", e);
None None
} }
} }
@ -412,7 +412,7 @@ fn cargo_config_build_target(cargo_toml: &ManifestPath) -> Option<String> {
.args(&["-Z", "unstable-options", "config", "get", "build.target"]) .args(&["-Z", "unstable-options", "config", "get", "build.target"])
.env("RUSTC_BOOTSTRAP", "1"); .env("RUSTC_BOOTSTRAP", "1");
// if successful we receive `build.target = "target-triple"` // if successful we receive `build.target = "target-triple"`
log::debug!("Discovering cargo config target by {:?}", cargo_config); tracing::debug!("Discovering cargo config target by {:?}", cargo_config);
match utf8_stdout(cargo_config) { match utf8_stdout(cargo_config) {
Ok(stdout) => stdout Ok(stdout) => stdout
.strip_prefix("build.target = \"") .strip_prefix("build.target = \"")

View file

@ -20,7 +20,7 @@ pub(crate) fn get(cargo_toml: Option<&ManifestPath>, target: Option<&str>) -> Ve
match get_rust_cfgs(cargo_toml, target) { match get_rust_cfgs(cargo_toml, target) {
Ok(rustc_cfgs) => res.extend(rustc_cfgs.lines().map(|it| it.parse().unwrap())), Ok(rustc_cfgs) => res.extend(rustc_cfgs.lines().map(|it| it.parse().unwrap())),
Err(e) => log::error!("failed to get rustc cfgs: {:#}", e), Err(e) => tracing::error!("failed to get rustc cfgs: {:#}", e),
} }
res res

View file

@ -54,7 +54,7 @@ impl Sysroot {
} }
pub fn discover(dir: &AbsPath) -> Result<Sysroot> { pub fn discover(dir: &AbsPath) -> Result<Sysroot> {
log::debug!("Discovering sysroot for {}", dir.display()); tracing::debug!("Discovering sysroot for {}", dir.display());
let sysroot_dir = discover_sysroot_dir(dir)?; let sysroot_dir = discover_sysroot_dir(dir)?;
let sysroot_src_dir = discover_sysroot_src_dir(&sysroot_dir, dir)?; let sysroot_src_dir = discover_sysroot_src_dir(&sysroot_dir, dir)?;
let res = Sysroot::load(sysroot_src_dir)?; let res = Sysroot::load(sysroot_src_dir)?;
@ -62,7 +62,7 @@ impl Sysroot {
} }
pub fn discover_rustc(cargo_toml: &ManifestPath) -> Option<ManifestPath> { pub fn discover_rustc(cargo_toml: &ManifestPath) -> Option<ManifestPath> {
log::debug!("Discovering rustc source for {}", cargo_toml.display()); tracing::debug!("Discovering rustc source for {}", cargo_toml.display());
let current_dir = cargo_toml.parent(); let current_dir = cargo_toml.parent();
discover_sysroot_dir(current_dir).ok().and_then(|sysroot_dir| get_rustc_src(&sysroot_dir)) discover_sysroot_dir(current_dir).ok().and_then(|sysroot_dir| get_rustc_src(&sysroot_dir))
} }
@ -132,7 +132,7 @@ impl Sysroot {
fn discover_sysroot_dir(current_dir: &AbsPath) -> Result<AbsPathBuf> { fn discover_sysroot_dir(current_dir: &AbsPath) -> Result<AbsPathBuf> {
let mut rustc = Command::new(toolchain::rustc()); let mut rustc = Command::new(toolchain::rustc());
rustc.current_dir(current_dir).args(&["--print", "sysroot"]); rustc.current_dir(current_dir).args(&["--print", "sysroot"]);
log::debug!("Discovering sysroot by {:?}", rustc); tracing::debug!("Discovering sysroot by {:?}", rustc);
let stdout = utf8_stdout(rustc)?; let stdout = utf8_stdout(rustc)?;
Ok(AbsPathBuf::assert(PathBuf::from(stdout))) Ok(AbsPathBuf::assert(PathBuf::from(stdout)))
} }
@ -146,10 +146,10 @@ fn discover_sysroot_src_dir(
.map_err(|path| format_err!("RUST_SRC_PATH must be absolute: {}", path.display()))?; .map_err(|path| format_err!("RUST_SRC_PATH must be absolute: {}", path.display()))?;
let core = path.join("core"); let core = path.join("core");
if fs::metadata(&core).is_ok() { if fs::metadata(&core).is_ok() {
log::debug!("Discovered sysroot by RUST_SRC_PATH: {}", path.display()); tracing::debug!("Discovered sysroot by RUST_SRC_PATH: {}", path.display());
return Ok(path); return Ok(path);
} }
log::debug!("RUST_SRC_PATH is set, but is invalid (no core: {:?}), ignoring", core); tracing::debug!("RUST_SRC_PATH is set, but is invalid (no core: {:?}), ignoring", core);
} }
get_rust_src(sysroot_path) get_rust_src(sysroot_path)
@ -174,7 +174,7 @@ try installing the Rust source the same way you installed rustc",
fn get_rustc_src(sysroot_path: &AbsPath) -> Option<ManifestPath> { fn get_rustc_src(sysroot_path: &AbsPath) -> Option<ManifestPath> {
let rustc_src = sysroot_path.join("lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml"); let rustc_src = sysroot_path.join("lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml");
let rustc_src = ManifestPath::try_from(rustc_src).ok()?; let rustc_src = ManifestPath::try_from(rustc_src).ok()?;
log::debug!("Checking for rustc source code: {}", rustc_src.display()); tracing::debug!("Checking for rustc source code: {}", rustc_src.display());
if fs::metadata(&rustc_src).is_ok() { if fs::metadata(&rustc_src).is_ok() {
Some(rustc_src) Some(rustc_src)
} else { } else {
@ -185,7 +185,10 @@ fn get_rustc_src(sysroot_path: &AbsPath) -> Option<ManifestPath> {
fn get_rust_src(sysroot_path: &AbsPath) -> Option<AbsPathBuf> { fn get_rust_src(sysroot_path: &AbsPath) -> Option<AbsPathBuf> {
// Try the new path first since the old one still exists. // Try the new path first since the old one still exists.
let rust_src = sysroot_path.join("lib/rustlib/src/rust"); let rust_src = sysroot_path.join("lib/rustlib/src/rust");
log::debug!("Checking sysroot (looking for `library` and `src` dirs): {}", rust_src.display()); tracing::debug!(
"Checking sysroot (looking for `library` and `src` dirs): {}",
rust_src.display()
);
["library", "src"].iter().map(|it| rust_src.join(it)).find(|it| fs::metadata(it).is_ok()) ["library", "src"].iter().map(|it| rust_src.join(it)).find(|it| fs::metadata(it).is_ok())
} }

View file

@ -384,9 +384,9 @@ impl ProjectWorkspace {
} }
}; };
if crate_graph.patch_cfg_if() { if crate_graph.patch_cfg_if() {
log::debug!("Patched std to depend on cfg-if") tracing::debug!("Patched std to depend on cfg-if")
} else { } else {
log::debug!("Did not patch std to depend on cfg-if") tracing::debug!("Did not patch std to depend on cfg-if")
} }
crate_graph crate_graph
} }
@ -623,7 +623,7 @@ fn detached_files_to_crate_graph(
let file_id = match load(detached_file) { let file_id = match load(detached_file) {
Some(file_id) => file_id, Some(file_id) => file_id,
None => { None => {
log::error!("Failed to load detached file {:?}", detached_file); tracing::error!("Failed to load detached file {:?}", detached_file);
continue; continue;
} }
}; };
@ -847,7 +847,7 @@ fn sysroot_to_crate_graph(
fn add_dep(graph: &mut CrateGraph, from: CrateId, name: CrateName, to: CrateId) { fn add_dep(graph: &mut CrateGraph, from: CrateId, name: CrateName, to: CrateId) {
if let Err(err) = graph.add_dep(from, name, to) { if let Err(err) = graph.add_dep(from, name, to) {
log::error!("{}", err) tracing::error!("{}", err)
} }
} }

View file

@ -20,10 +20,8 @@ path = "src/bin/main.rs"
anyhow = "1.0.26" anyhow = "1.0.26"
crossbeam-channel = "0.5.0" crossbeam-channel = "0.5.0"
dissimilar = "1.0.2" dissimilar = "1.0.2"
env_logger = { version = "0.9", default-features = false }
itertools = "0.10.0" itertools = "0.10.0"
jod-thread = "0.1.0" jod-thread = "0.1.0"
log = "0.4.8"
lsp-types = { version = "0.89.0", features = ["proposed"] } lsp-types = { version = "0.89.0", features = ["proposed"] }
parking_lot = "0.11.0" parking_lot = "0.11.0"
xflags = "0.2.1" xflags = "0.2.1"
@ -36,7 +34,8 @@ rayon = "1.5"
mimalloc = { version = "0.1.19", default-features = false, optional = true } mimalloc = { version = "0.1.19", default-features = false, optional = true }
lsp-server = "0.5.1" lsp-server = "0.5.1"
tracing = "0.1" tracing = "0.1"
tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry", "fmt", "tracing-log"] }
tracing-log = "0.1.2"
tracing-tree = { version = "0.1.4" } tracing-tree = { version = "0.1.4" }
always-assert = "0.1" always-assert = "0.1"

View file

@ -1,88 +1,142 @@
//! Simple logger that logs either to stderr or to a file, using `env_logger` //! Simple logger that logs either to stderr or to a file, using `tracing_subscriber`
//! filter syntax. Amusingly, there's no crates.io crate that can do this and //! filter syntax and `tracing_appender` for non blocking output.
//! only this.
use std::{ use std::{
fmt::{self, Write},
fs::File, fs::File,
io::{self, BufWriter, Write}, io,
sync::Arc,
}; };
use env_logger::filter::{Builder, Filter}; use rust_analyzer::Result;
use log::{Log, Metadata, Record}; use tracing::{level_filters::LevelFilter, Event, Subscriber};
use parking_lot::Mutex; use tracing_log::NormalizeEvent;
use tracing_subscriber::{
fmt::{writer::BoxMakeWriter, FmtContext, FormatEvent, FormatFields, FormattedFields},
layer::SubscriberExt,
registry::LookupSpan,
util::SubscriberInitExt,
EnvFilter, Registry,
};
use tracing_tree::HierarchicalLayer;
pub(crate) struct Logger { pub(crate) struct Logger {
filter: Filter, filter: EnvFilter,
file: Option<Mutex<BufWriter<File>>>, file: Option<File>,
no_buffering: bool,
} }
impl Logger { impl Logger {
pub(crate) fn new(log_file: Option<File>, no_buffering: bool, filter: Option<&str>) -> Logger { pub(crate) fn new(file: Option<File>, filter: Option<&str>) -> Logger {
let filter = { let filter = filter.map_or(EnvFilter::default(), |dirs| EnvFilter::new(dirs));
let mut builder = Builder::new();
if let Some(filter) = filter { Logger { filter, file }
builder.parse(filter);
} }
builder.build()
pub(crate) fn install(self) -> Result<()> {
// The meaning of CHALK_DEBUG I suspected is to tell chalk crates
// (i.e. chalk-solve, chalk-ir, chalk-recursive) how to filter tracing
// logs. But now we can only have just one filter, which means we have to
// merge chalk filter to our main filter (from RA_LOG env).
//
// The acceptable syntax of CHALK_DEBUG is `target[span{field=value}]=level`.
// As the value should only affect chalk crates, we'd better mannually
// specify the target. And for simplicity, CHALK_DEBUG only accept the value
// that specify level.
let chalk_level_dir = std::env::var("CHALK_DEBUG")
.map(|val| {
val.parse::<LevelFilter>().expect(
"invalid CHALK_DEBUG value, expect right log level (like debug or trace)",
)
})
.ok();
let chalk_layer = HierarchicalLayer::default()
.with_indent_lines(true)
.with_ansi(false)
.with_indent_amount(2)
.with_writer(std::io::stderr);
let writer = match self.file {
Some(file) => BoxMakeWriter::new(Arc::new(file)),
None => BoxMakeWriter::new(io::stderr),
}; };
let ra_fmt_layer =
tracing_subscriber::fmt::layer().event_format(LoggerFormatter).with_writer(writer);
let file = log_file.map(|it| Mutex::new(BufWriter::new(it))); match chalk_level_dir {
Some(val) => {
Logger { filter, file, no_buffering } Registry::default()
} .with(
self.filter
pub(crate) fn install(self) { .add_directive(format!("chalk_solve={}", val).parse()?)
let max_level = self.filter.filter(); .add_directive(format!("chalk_ir={}", val).parse()?)
let _ = log::set_boxed_logger(Box::new(self)).map(|()| log::set_max_level(max_level)); .add_directive(format!("chalk_recursive={}", val).parse()?),
} )
} .with(ra_fmt_layer)
.with(chalk_layer)
impl Log for Logger { .init();
fn enabled(&self, metadata: &Metadata) -> bool {
self.filter.enabled(metadata)
}
fn log(&self, record: &Record) {
if !self.filter.matches(record) {
return;
}
match &self.file {
Some(w) => {
let mut writer = w.lock();
let _ = writeln!(
writer,
"[{} {}] {}",
record.level(),
record.module_path().unwrap_or_default(),
record.args(),
);
if self.no_buffering {
let _ = writer.flush();
}
} }
None => { None => {
let message = format!( Registry::default().with(self.filter).with(ra_fmt_layer).init();
"[{} {}] {}\n",
record.level(),
record.module_path().unwrap_or_default(),
record.args(),
);
eprint!("{}", message);
} }
}; };
Ok(())
}
} }
fn flush(&self) { #[derive(Debug)]
match &self.file { struct LoggerFormatter;
Some(w) => {
let _ = w.lock().flush(); impl<S, N> FormatEvent<S, N> for LoggerFormatter
} where
None => { S: Subscriber + for<'a> LookupSpan<'a>,
let _ = io::stderr().flush(); N: for<'a> FormatFields<'a> + 'static,
} {
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
writer: &mut dyn Write,
event: &Event<'_>,
) -> fmt::Result {
// Write level and target
let level = *event.metadata().level();
// If this event is issued from `log` crate, then the value of target is
// always "log". `tracing-log` has hard coded it for some reason, so we
// need to extract it using `normalized_metadata` method which is part of
// `tracing_log::NormalizeEvent`.
let target = match event.normalized_metadata() {
// This event is issued from `log` crate
Some(log) => log.target(),
None => event.metadata().target(),
};
write!(writer, "[{} {}] ", level, target)?;
// Write spans and fields of each span
ctx.visit_spans(|span| {
write!(writer, "{}", span.name())?;
let ext = span.extensions();
// `FormattedFields` is a a formatted representation of the span's
// fields, which is stored in its extensions by the `fmt` layer's
// `new_span` method. The fields will have been formatted
// by the same field formatter that's provided to the event
// formatter in the `FmtContext`.
let fields = &ext.get::<FormattedFields<N>>().expect("will never be `None`");
if !fields.is_empty() {
write!(writer, "{{{}}}", fields)?;
} }
write!(writer, ": ")?;
Ok(())
})?;
// Write fields on the event
ctx.field_format().format_fields(writer, event)?;
writeln!(writer)
} }
} }

View file

@ -35,7 +35,7 @@ fn main() {
} }
if let Err(err) = try_main() { if let Err(err) = try_main() {
log::error!("Unexpected error: {}", err); tracing::error!("Unexpected error: {}", err);
eprintln!("{}", err); eprintln!("{}", err);
process::exit(101); process::exit(101);
} }
@ -60,7 +60,7 @@ fn try_main() -> Result<()> {
log_file = Some(Path::new(env_log_file)); log_file = Some(Path::new(env_log_file));
} }
setup_logging(log_file, flags.no_log_buffering)?; setup_logging(log_file)?;
let verbosity = flags.verbosity(); let verbosity = flags.verbosity();
match flags.subcommand { match flags.subcommand {
@ -91,7 +91,7 @@ fn try_main() -> Result<()> {
Ok(()) Ok(())
} }
fn setup_logging(log_file: Option<&Path>, no_buffering: bool) -> Result<()> { fn setup_logging(log_file: Option<&Path>) -> Result<()> {
env::set_var("RUST_BACKTRACE", "short"); env::set_var("RUST_BACKTRACE", "short");
let log_file = match log_file { let log_file = match log_file {
@ -104,42 +104,20 @@ fn setup_logging(log_file: Option<&Path>, no_buffering: bool) -> Result<()> {
None => None, None => None,
}; };
let filter = env::var("RA_LOG").ok(); let filter = env::var("RA_LOG").ok();
logger::Logger::new(log_file, no_buffering, filter.as_deref()).install(); logger::Logger::new(log_file, filter.as_deref()).install()?;
tracing_setup::setup_tracing()?;
profile::init(); profile::init();
Ok(()) Ok(())
} }
mod tracing_setup {
use tracing::subscriber;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::Registry;
use tracing_tree::HierarchicalLayer;
pub(crate) fn setup_tracing() -> super::Result<()> {
let filter = EnvFilter::from_env("CHALK_DEBUG");
let layer = HierarchicalLayer::default()
.with_indent_lines(true)
.with_ansi(false)
.with_indent_amount(2)
.with_writer(std::io::stderr);
let subscriber = Registry::default().with(filter).with(layer);
subscriber::set_global_default(subscriber)?;
Ok(())
}
}
fn run_server() -> Result<()> { fn run_server() -> Result<()> {
log::info!("server version {} will start", env!("REV")); tracing::info!("server version {} will start", env!("REV"));
let (connection, io_threads) = Connection::stdio(); let (connection, io_threads) = Connection::stdio();
let (initialize_id, initialize_params) = connection.initialize_start()?; let (initialize_id, initialize_params) = connection.initialize_start()?;
log::info!("InitializeParams: {}", initialize_params); tracing::info!("InitializeParams: {}", initialize_params);
let initialize_params = let initialize_params =
from_json::<lsp_types::InitializeParams>("InitializeParams", initialize_params)?; from_json::<lsp_types::InitializeParams>("InitializeParams", initialize_params)?;
@ -176,7 +154,7 @@ fn run_server() -> Result<()> {
connection.initialize_finish(initialize_id, initialize_result)?; connection.initialize_finish(initialize_id, initialize_result)?;
if let Some(client_info) = initialize_params.client_info { if let Some(client_info) = initialize_params.client_info {
log::info!("Client '{}' {}", client_info.name, client_info.version.unwrap_or_default()); tracing::info!("Client '{}' {}", client_info.name, client_info.version.unwrap_or_default());
} }
if config.linked_projects().is_empty() && config.detached_files().is_empty() { if config.linked_projects().is_empty() && config.detached_files().is_empty() {
@ -193,9 +171,9 @@ fn run_server() -> Result<()> {
.unwrap_or_else(|| vec![config.root_path.clone()]); .unwrap_or_else(|| vec![config.root_path.clone()]);
let discovered = ProjectManifest::discover_all(&workspace_roots); let discovered = ProjectManifest::discover_all(&workspace_roots);
log::info!("discovered projects: {:?}", discovered); tracing::info!("discovered projects: {:?}", discovered);
if discovered.is_empty() { if discovered.is_empty() {
log::error!("failed to find any projects in {:?}", workspace_roots); tracing::error!("failed to find any projects in {:?}", workspace_roots);
} }
config.discovered_projects = Some(discovered); config.discovered_projects = Some(discovered);
} }
@ -203,6 +181,6 @@ fn run_server() -> Result<()> {
rust_analyzer::main_loop(config, connection)?; rust_analyzer::main_loop(config, connection)?;
io_threads.join()?; io_threads.join()?;
log::info!("server did shut down"); tracing::info!("server did shut down");
Ok(()) Ok(())
} }

View file

@ -131,7 +131,7 @@ fn completions_resolve_provider(client_caps: &ClientCapabilities) -> Option<bool
if completion_item_edit_resolve(client_caps) { if completion_item_edit_resolve(client_caps) {
Some(true) Some(true)
} else { } else {
log::info!("No `additionalTextEdits` completion resolve capability was found in the client capabilities, autoimport completion is disabled"); tracing::info!("No `additionalTextEdits` completion resolve capability was found in the client capabilities, autoimport completion is disabled");
None None
} }
} }

View file

@ -85,7 +85,7 @@ pub fn load_workspace(
version: 0, version: 0,
}); });
log::debug!("crate graph: {:?}", crate_graph); tracing::debug!("crate graph: {:?}", crate_graph);
let host = let host =
load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver); load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver);

View file

@ -432,7 +432,7 @@ impl Config {
} }
} }
pub fn update(&mut self, mut json: serde_json::Value) { pub fn update(&mut self, mut json: serde_json::Value) {
log::info!("updating config from JSON: {:#}", json); tracing::info!("updating config from JSON: {:#}", json);
if json.is_null() || json.as_object().map_or(false, |it| it.is_empty()) { if json.is_null() || json.as_object().map_or(false, |it| it.is_empty()) {
return; return;
} }
@ -478,7 +478,9 @@ impl Config {
ManifestOrProjectJson::Manifest(it) => { ManifestOrProjectJson::Manifest(it) => {
let path = self.root_path.join(it); let path = self.root_path.join(it);
ProjectManifest::from_manifest_file(path) ProjectManifest::from_manifest_file(path)
.map_err(|e| log::error!("failed to load linked project: {}", e)) .map_err(|e| {
tracing::error!("failed to load linked project: {}", e)
})
.ok()? .ok()?
.into() .into()
} }

View file

@ -88,7 +88,7 @@ impl<'a> RequestDispatcher<'a> {
pub(crate) fn finish(&mut self) { pub(crate) fn finish(&mut self) {
if let Some(req) = self.req.take() { if let Some(req) = self.req.take() {
log::error!("unknown request: {:?}", req); tracing::error!("unknown request: {:?}", req);
let response = lsp_server::Response::new_err( let response = lsp_server::Response::new_err(
req.id, req.id,
lsp_server::ErrorCode::MethodNotFound as i32, lsp_server::ErrorCode::MethodNotFound as i32,
@ -208,7 +208,7 @@ impl<'a> NotificationDispatcher<'a> {
pub(crate) fn finish(&mut self) { pub(crate) fn finish(&mut self) {
if let Some(not) = &self.not { if let Some(not) = &self.not {
if !not.method.starts_with("$/") { if !not.method.starts_with("$/") {
log::error!("unhandled notification: {:?}", not); tracing::error!("unhandled notification: {:?}", not);
} }
} }
} }

View file

@ -271,7 +271,7 @@ impl GlobalState {
} }
let duration = start.elapsed(); let duration = start.elapsed();
log::info!("handled {} - ({}) in {:0.2?}", method, response.id, duration); tracing::info!("handled {} - ({}) in {:0.2?}", method, response.id, duration);
self.send(response.into()); self.send(response.into());
} }
} }

View file

@ -1651,7 +1651,7 @@ fn run_rustfmt(
} }
} }
Err(_) => { Err(_) => {
log::error!( tracing::error!(
"Unable to get file path for {}, rustfmt.toml might be ignored", "Unable to get file path for {}, rustfmt.toml might be ignored",
text_document.uri text_document.uri
); );
@ -1721,7 +1721,7 @@ fn run_rustfmt(
// formatting because otherwise an error is surfaced to the user on top of the // formatting because otherwise an error is surfaced to the user on top of the
// syntax error diagnostics they're already receiving. This is especially jarring // syntax error diagnostics they're already receiving. This is especially jarring
// if they have format on save enabled. // if they have format on save enabled.
log::info!("rustfmt exited with status 1, assuming parse error and ignoring"); tracing::info!("rustfmt exited with status 1, assuming parse error and ignoring");
Ok(None) Ok(None)
} }
_ => { _ => {

View file

@ -27,7 +27,7 @@ use crate::{
}; };
pub fn main_loop(config: Config, connection: Connection) -> Result<()> { pub fn main_loop(config: Config, connection: Connection) -> Result<()> {
log::info!("initial config: {:#?}", config); tracing::info!("initial config: {:#?}", config);
// Windows scheduler implements priority boosts: if thread waits for an // Windows scheduler implements priority boosts: if thread waits for an
// event (like a condvar), and event fires, priority of the thread is // event (like a condvar), and event fires, priority of the thread is
@ -182,10 +182,10 @@ impl GlobalState {
// NOTE: don't count blocking select! call as a loop-turn time // NOTE: don't count blocking select! call as a loop-turn time
let _p = profile::span("GlobalState::handle_event"); let _p = profile::span("GlobalState::handle_event");
log::info!("handle_event({:?})", event); tracing::info!("handle_event({:?})", event);
let task_queue_len = self.task_pool.handle.len(); let task_queue_len = self.task_pool.handle.len();
if task_queue_len > 0 { if task_queue_len > 0 {
log::info!("task queue len: {}", task_queue_len); tracing::info!("task queue len: {}", task_queue_len);
} }
let was_quiescent = self.is_quiescent(); let was_quiescent = self.is_quiescent();
@ -359,7 +359,7 @@ impl GlobalState {
diag.fixes, diag.fixes,
), ),
Err(err) => { Err(err) => {
log::error!( tracing::error!(
"File with cargo diagnostic not found in VFS: {}", "File with cargo diagnostic not found in VFS: {}",
err err
); );
@ -380,7 +380,7 @@ impl GlobalState {
flycheck::Progress::DidCancel => (Progress::End, None), flycheck::Progress::DidCancel => (Progress::End, None),
flycheck::Progress::DidFinish(result) => { flycheck::Progress::DidFinish(result) => {
if let Err(err) = result { if let Err(err) = result {
log::error!("cargo check failed: {}", err) tracing::error!("cargo check failed: {}", err)
} }
(Progress::End, None) (Progress::End, None)
} }
@ -486,7 +486,7 @@ impl GlobalState {
let loop_duration = loop_start.elapsed(); let loop_duration = loop_start.elapsed();
if loop_duration > Duration::from_millis(100) { if loop_duration > Duration::from_millis(100) {
log::warn!("overly long loop turn: {:?}", loop_duration); tracing::warn!("overly long loop turn: {:?}", loop_duration);
self.poke_rust_analyzer_developer(format!( self.poke_rust_analyzer_developer(format!(
"overly long loop turn: {:?}", "overly long loop turn: {:?}",
loop_duration loop_duration
@ -617,7 +617,7 @@ impl GlobalState {
.insert(path.clone(), DocumentData::new(params.text_document.version)) .insert(path.clone(), DocumentData::new(params.text_document.version))
.is_err() .is_err()
{ {
log::error!("duplicate DidOpenTextDocument: {}", path) tracing::error!("duplicate DidOpenTextDocument: {}", path)
} }
this.vfs this.vfs
.write() .write()
@ -635,7 +635,7 @@ impl GlobalState {
doc.version = params.text_document.version; doc.version = params.text_document.version;
} }
None => { None => {
log::error!("expected DidChangeTextDocument: {}", path); tracing::error!("expected DidChangeTextDocument: {}", path);
return Ok(()); return Ok(());
} }
}; };
@ -652,7 +652,7 @@ impl GlobalState {
.on::<lsp_types::notification::DidCloseTextDocument>(|this, params| { .on::<lsp_types::notification::DidCloseTextDocument>(|this, params| {
if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) { if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) {
if this.mem_docs.remove(&path).is_err() { if this.mem_docs.remove(&path).is_err() {
log::error!("orphan DidCloseTextDocument: {}", path); tracing::error!("orphan DidCloseTextDocument: {}", path);
} }
this.semantic_tokens_cache.lock().remove(&params.text_document.uri); this.semantic_tokens_cache.lock().remove(&params.text_document.uri);
@ -683,12 +683,12 @@ impl GlobalState {
}], }],
}, },
|this, resp| { |this, resp| {
log::debug!("config update response: '{:?}", resp); tracing::debug!("config update response: '{:?}", resp);
let lsp_server::Response { error, result, .. } = resp; let lsp_server::Response { error, result, .. } = resp;
match (error, result) { match (error, result) {
(Some(err), _) => { (Some(err), _) => {
log::error!("failed to fetch the server settings: {:?}", err) tracing::error!("failed to fetch the server settings: {:?}", err)
} }
(None, Some(mut configs)) => { (None, Some(mut configs)) => {
if let Some(json) = configs.get_mut(0) { if let Some(json) = configs.get_mut(0) {
@ -699,7 +699,7 @@ impl GlobalState {
this.update_configuration(config); this.update_configuration(config);
} }
} }
(None, None) => log::error!( (None, None) => tracing::error!(
"received empty server settings response from the client" "received empty server settings response from the client"
), ),
} }
@ -727,7 +727,7 @@ impl GlobalState {
.map(|path| self.vfs.read().0.file_id(path).unwrap()) .map(|path| self.vfs.read().0.file_id(path).unwrap())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
log::trace!("updating notifications for {:?}", subscriptions); tracing::trace!("updating notifications for {:?}", subscriptions);
let snapshot = self.snapshot(); let snapshot = self.snapshot();
self.task_pool.handle.spawn(move || { self.task_pool.handle.spawn(move || {
@ -737,7 +737,7 @@ impl GlobalState {
handlers::publish_diagnostics(&snapshot, file_id) handlers::publish_diagnostics(&snapshot, file_id)
.map_err(|err| { .map_err(|err| {
if !is_cancelled(&*err) { if !is_cancelled(&*err) {
log::error!("failed to compute diagnostics: {:?}", err); tracing::error!("failed to compute diagnostics: {:?}", err);
} }
() ()
}) })

View file

@ -61,7 +61,7 @@ impl GlobalState {
if !changes.iter().any(|(path, kind)| is_interesting(path, *kind)) { if !changes.iter().any(|(path, kind)| is_interesting(path, *kind)) {
return; return;
} }
log::info!( tracing::info!(
"Requesting workspace reload because of the following changes: {}", "Requesting workspace reload because of the following changes: {}",
itertools::join( itertools::join(
changes changes
@ -153,7 +153,7 @@ impl GlobalState {
if !self.fetch_workspaces_queue.should_start_op() { if !self.fetch_workspaces_queue.should_start_op() {
return; return;
} }
log::info!("will fetch workspaces"); tracing::info!("will fetch workspaces");
self.task_pool.handle.spawn_with_sender({ self.task_pool.handle.spawn_with_sender({
let linked_projects = self.config.linked_projects(); let linked_projects = self.config.linked_projects();
@ -196,7 +196,7 @@ impl GlobalState {
.push(project_model::ProjectWorkspace::load_detached_files(detached_files)); .push(project_model::ProjectWorkspace::load_detached_files(detached_files));
} }
log::info!("did fetch workspaces {:?}", workspaces); tracing::info!("did fetch workspaces {:?}", workspaces);
sender sender
.send(Task::FetchWorkspace(ProjectWorkspaceProgress::End(workspaces))) .send(Task::FetchWorkspace(ProjectWorkspaceProgress::End(workspaces)))
.unwrap(); .unwrap();
@ -245,10 +245,10 @@ impl GlobalState {
pub(crate) fn switch_workspaces(&mut self) { pub(crate) fn switch_workspaces(&mut self) {
let _p = profile::span("GlobalState::switch_workspaces"); let _p = profile::span("GlobalState::switch_workspaces");
log::info!("will switch workspaces"); tracing::info!("will switch workspaces");
if let Some(error_message) = self.fetch_workspace_error() { if let Some(error_message) = self.fetch_workspace_error() {
log::error!("failed to switch workspaces: {}", error_message); tracing::error!("failed to switch workspaces: {}", error_message);
if !self.workspaces.is_empty() { if !self.workspaces.is_empty() {
// It only makes sense to switch to a partially broken workspace // It only makes sense to switch to a partially broken workspace
// if we don't have any workspace at all yet. // if we don't have any workspace at all yet.
@ -257,7 +257,7 @@ impl GlobalState {
} }
if let Some(error_message) = self.fetch_build_data_error() { if let Some(error_message) = self.fetch_build_data_error() {
log::error!("failed to switch build data: {}", error_message); tracing::error!("failed to switch build data: {}", error_message);
} }
let workspaces = self let workspaces = self
@ -367,7 +367,7 @@ impl GlobalState {
Some((path, args)) => match ProcMacroClient::extern_process(path.clone(), args) { Some((path, args)) => match ProcMacroClient::extern_process(path.clone(), args) {
Ok(it) => Some(it), Ok(it) => Some(it),
Err(err) => { Err(err) => {
log::error!( tracing::error!(
"Failed to run proc_macro_srv from path {}, error: {:?}", "Failed to run proc_macro_srv from path {}, error: {:?}",
path.display(), path.display(),
err err
@ -407,7 +407,7 @@ impl GlobalState {
} }
let res = vfs.file_id(&vfs_path); let res = vfs.file_id(&vfs_path);
if res.is_none() { if res.is_none() {
log::warn!("failed to load {}", path.display()) tracing::warn!("failed to load {}", path.display())
} }
res res
}; };
@ -425,7 +425,7 @@ impl GlobalState {
self.analysis_host.apply_change(change); self.analysis_host.apply_change(change);
self.process_changes(); self.process_changes();
self.reload_flycheck(); self.reload_flycheck();
log::info!("did switch workspaces"); tracing::info!("did switch workspaces");
} }
fn fetch_workspace_error(&self) -> Option<String> { fn fetch_workspace_error(&self) -> Option<String> {

View file

@ -71,7 +71,10 @@ impl<'a> Project<'a> {
let tmp_dir = self.tmp_dir.unwrap_or_else(TestDir::new); let tmp_dir = self.tmp_dir.unwrap_or_else(TestDir::new);
static INIT: Once = Once::new(); static INIT: Once = Once::new();
INIT.call_once(|| { INIT.call_once(|| {
env_logger::builder().is_test(true).parse_env("RA_LOG").try_init().unwrap(); tracing_subscriber::fmt()
.with_test_writer()
.with_env_filter(tracing_subscriber::EnvFilter::from_env("RA_LOG"))
.init();
profile::init_from(crate::PROFILE); profile::init_from(crate::PROFILE);
}); });

View file

@ -9,7 +9,7 @@ edition = "2018"
doctest = false doctest = false
[dependencies] [dependencies]
log = "0.4.8" tracing = "0.1"
rustc-hash = "1.0" rustc-hash = "1.0"
jod-thread = "0.1.0" jod-thread = "0.1.0"
walkdir = "2.3.1" walkdir = "2.3.1"

View file

@ -76,7 +76,7 @@ impl NotifyActor {
} }
fn run(mut self, inbox: Receiver<Message>) { fn run(mut self, inbox: Receiver<Message>) {
while let Some(event) = self.next_event(&inbox) { while let Some(event) = self.next_event(&inbox) {
log::debug!("vfs-notify event: {:?}", event); tracing::debug!("vfs-notify event: {:?}", event);
match event { match event {
Event::Message(msg) => match msg { Event::Message(msg) => match msg {
Message::Config(config) => { Message::Config(config) => {
@ -227,5 +227,5 @@ fn read(path: &AbsPath) -> Option<Vec<u8>> {
} }
fn log_notify_error<T>(res: notify::Result<T>) -> Option<T> { fn log_notify_error<T>(res: notify::Result<T>) -> Option<T> {
res.map_err(|err| log::warn!("notify error: {}", err)).ok() res.map_err(|err| tracing::warn!("notify error: {}", err)).ok()
} }