mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
Bump tracing
This commit is contained in:
parent
49b0970970
commit
3678cbd12e
4 changed files with 29 additions and 16 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -881,9 +881,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matchers"
|
name = "matchers"
|
||||||
version = "0.0.1"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
|
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"regex-automata",
|
"regex-automata",
|
||||||
]
|
]
|
||||||
|
@ -1731,9 +1731,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-subscriber"
|
name = "tracing-subscriber"
|
||||||
version = "0.2.25"
|
version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71"
|
checksum = "245da694cc7fc4729f3f418b304cb57789f1bed2a78c575407ab8a23f53cb4d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"matchers",
|
"matchers",
|
||||||
|
@ -1747,9 +1747,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-tree"
|
name = "tracing-tree"
|
||||||
version = "0.1.11"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2a408a91fbd4850982080e643a261aef2a2ef72c8263ce353b61d25acfc2c49"
|
checksum = "3ce989c9962c7f61fe084dd4a230eec784649dfc2392467c790007c3a6e134e7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
"atty",
|
"atty",
|
||||||
|
|
|
@ -36,8 +36,8 @@ limit = { path = "../limit", version = "0.0.0" }
|
||||||
test_utils = { path = "../test_utils" }
|
test_utils = { path = "../test_utils" }
|
||||||
expect-test = "1.2.0-pre.1"
|
expect-test = "1.2.0-pre.1"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = { version = "0.2", default-features = false, features = [
|
tracing-subscriber = { version = "0.3", default-features = false, features = [
|
||||||
"env-filter",
|
"env-filter",
|
||||||
"registry",
|
"registry",
|
||||||
] }
|
] }
|
||||||
tracing-tree = { version = "0.1.10" }
|
tracing-tree = "0.2"
|
||||||
|
|
|
@ -34,14 +34,14 @@ 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 = [
|
tracing-subscriber = { version = "0.3", default-features = false, features = [
|
||||||
"env-filter",
|
"env-filter",
|
||||||
"registry",
|
"registry",
|
||||||
"fmt",
|
"fmt",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
] }
|
] }
|
||||||
tracing-log = "0.1.2"
|
tracing-log = "0.1.2"
|
||||||
tracing-tree = { version = "0.1.10" }
|
tracing-tree = "0.2"
|
||||||
always-assert = "0.1"
|
always-assert = "0.1"
|
||||||
|
|
||||||
stdx = { path = "../stdx", version = "0.0.0" }
|
stdx = { path = "../stdx", version = "0.0.0" }
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
//! filter syntax and `tracing_appender` for non blocking output.
|
//! filter syntax and `tracing_appender` for non blocking output.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{self, Write},
|
fmt,
|
||||||
fs::File,
|
fs::File,
|
||||||
io,
|
io::{self, Stderr},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,7 +12,10 @@ use rust_analyzer::Result;
|
||||||
use tracing::{level_filters::LevelFilter, Event, Subscriber};
|
use tracing::{level_filters::LevelFilter, Event, Subscriber};
|
||||||
use tracing_log::NormalizeEvent;
|
use tracing_log::NormalizeEvent;
|
||||||
use tracing_subscriber::{
|
use tracing_subscriber::{
|
||||||
fmt::{writer::BoxMakeWriter, FmtContext, FormatEvent, FormatFields, FormattedFields},
|
fmt::{
|
||||||
|
format::Writer, writer::BoxMakeWriter, FmtContext, FormatEvent, FormatFields,
|
||||||
|
FormattedFields, MakeWriter,
|
||||||
|
},
|
||||||
layer::SubscriberExt,
|
layer::SubscriberExt,
|
||||||
registry::LookupSpan,
|
registry::LookupSpan,
|
||||||
util::SubscriberInitExt,
|
util::SubscriberInitExt,
|
||||||
|
@ -25,6 +28,16 @@ pub(crate) struct Logger {
|
||||||
file: Option<File>,
|
file: Option<File>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct MakeWriterStderr;
|
||||||
|
|
||||||
|
impl<'a> MakeWriter<'a> for MakeWriterStderr {
|
||||||
|
type Writer = Stderr;
|
||||||
|
|
||||||
|
fn make_writer(&'a self) -> Self::Writer {
|
||||||
|
io::stderr()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Logger {
|
impl Logger {
|
||||||
pub(crate) fn new(file: Option<File>, filter: Option<&str>) -> Logger {
|
pub(crate) fn new(file: Option<File>, filter: Option<&str>) -> Logger {
|
||||||
let filter = filter.map_or(EnvFilter::default(), EnvFilter::new);
|
let filter = filter.map_or(EnvFilter::default(), EnvFilter::new);
|
||||||
|
@ -54,7 +67,7 @@ impl Logger {
|
||||||
.with_indent_lines(true)
|
.with_indent_lines(true)
|
||||||
.with_ansi(false)
|
.with_ansi(false)
|
||||||
.with_indent_amount(2)
|
.with_indent_amount(2)
|
||||||
.with_writer(std::io::stderr);
|
.with_writer(io::stderr);
|
||||||
|
|
||||||
let writer = match self.file {
|
let writer = match self.file {
|
||||||
Some(file) => BoxMakeWriter::new(Arc::new(file)),
|
Some(file) => BoxMakeWriter::new(Arc::new(file)),
|
||||||
|
@ -96,7 +109,7 @@ where
|
||||||
fn format_event(
|
fn format_event(
|
||||||
&self,
|
&self,
|
||||||
ctx: &FmtContext<'_, S, N>,
|
ctx: &FmtContext<'_, S, N>,
|
||||||
writer: &mut dyn Write,
|
mut writer: Writer,
|
||||||
event: &Event<'_>,
|
event: &Event<'_>,
|
||||||
) -> fmt::Result {
|
) -> fmt::Result {
|
||||||
// Write level and target
|
// Write level and target
|
||||||
|
@ -135,7 +148,7 @@ where
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// Write fields on the event
|
// Write fields on the event
|
||||||
ctx.field_format().format_fields(writer, event)?;
|
ctx.field_format().format_fields(writer.by_ref(), event)?;
|
||||||
|
|
||||||
writeln!(writer)
|
writeln!(writer)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue