mirror of
https://github.com/tokio-rs/tracing.git
synced 2025-10-02 15:24:47 +00:00
tracing-subscriber: Switch to unconditional no_std
This commit is contained in:
parent
8738590fd1
commit
c297a37096
@ -1,7 +1,6 @@
|
|||||||
use crate::filter::level::{self, LevelFilter};
|
use crate::filter::level::{self, LevelFilter};
|
||||||
#[cfg(not(feature = "smallvec"))]
|
#[cfg(feature = "std")]
|
||||||
use alloc::vec;
|
use alloc::boxed::Box;
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
use alloc::{string::String, vec::Vec};
|
use alloc::{string::String, vec::Vec};
|
||||||
|
|
||||||
use core::{cmp::Ordering, fmt, iter::FromIterator, slice, str::FromStr};
|
use core::{cmp::Ordering, fmt, iter::FromIterator, slice, str::FromStr};
|
||||||
@ -126,7 +125,7 @@ impl<T> IntoIterator for DirectiveSet<T> {
|
|||||||
#[cfg(feature = "smallvec")]
|
#[cfg(feature = "smallvec")]
|
||||||
type IntoIter = smallvec::IntoIter<[T; 8]>;
|
type IntoIter = smallvec::IntoIter<[T; 8]>;
|
||||||
#[cfg(not(feature = "smallvec"))]
|
#[cfg(not(feature = "smallvec"))]
|
||||||
type IntoIter = vec::IntoIter<T>;
|
type IntoIter = alloc::vec::IntoIter<T>;
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
self.directives.into_iter()
|
self.directives.into_iter()
|
||||||
|
7
tracing-subscriber/src/filter/env/builder.rs
vendored
7
tracing-subscriber/src/filter/env/builder.rs
vendored
@ -3,7 +3,12 @@ use super::{
|
|||||||
EnvFilter, FromEnvError,
|
EnvFilter, FromEnvError,
|
||||||
};
|
};
|
||||||
use crate::sync::RwLock;
|
use crate::sync::RwLock;
|
||||||
use std::env;
|
use alloc::{
|
||||||
|
format,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
|
use std::{env, eprintln};
|
||||||
use thread_local::ThreadLocal;
|
use thread_local::ThreadLocal;
|
||||||
use tracing::level_filters::STATIC_MAX_LEVEL;
|
use tracing::level_filters::STATIC_MAX_LEVEL;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ use crate::filter::{
|
|||||||
env::{field, FieldMap},
|
env::{field, FieldMap},
|
||||||
level::LevelFilter,
|
level::LevelFilter,
|
||||||
};
|
};
|
||||||
|
use alloc::{borrow::ToOwned, string::String, vec::Vec};
|
||||||
use std::{cmp::Ordering, fmt, iter::FromIterator, str::FromStr};
|
use std::{cmp::Ordering, fmt, iter::FromIterator, str::FromStr};
|
||||||
use tracing_core::{span, Level, Metadata};
|
use tracing_core::{span, Level, Metadata};
|
||||||
|
|
||||||
@ -481,6 +482,7 @@ impl SpanMatcher {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use alloc::{format, string::ToString, vec};
|
||||||
|
|
||||||
fn parse_directives(dirs: impl AsRef<str>) -> Vec<Directive> {
|
fn parse_directives(dirs: impl AsRef<str>) -> Vec<Directive> {
|
||||||
dirs.as_ref()
|
dirs.as_ref()
|
||||||
|
23
tracing-subscriber/src/filter/env/field.rs
vendored
23
tracing-subscriber/src/filter/env/field.rs
vendored
@ -1,14 +1,17 @@
|
|||||||
use matchers::Pattern;
|
use alloc::{
|
||||||
use std::{
|
borrow::ToOwned,
|
||||||
|
boxed::Box,
|
||||||
|
string::{String, ToString},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
use core::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
error::Error,
|
|
||||||
fmt::{self, Write},
|
fmt::{self, Write},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::{
|
sync::atomic::{AtomicBool, Ordering::*},
|
||||||
atomic::{AtomicBool, Ordering::*},
|
|
||||||
Arc,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
use matchers::Pattern;
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
use super::{FieldMap, LevelFilter};
|
use super::{FieldMap, LevelFilter};
|
||||||
use tracing_core::field::{Field, Visit};
|
use tracing_core::field::{Field, Visit};
|
||||||
@ -507,9 +510,7 @@ impl Visit for MatchVisitor<'_> {
|
|||||||
Some((ValueMatch::NaN, ref matched)) if value.is_nan() => {
|
Some((ValueMatch::NaN, ref matched)) if value.is_nan() => {
|
||||||
matched.store(true, Release);
|
matched.store(true, Release);
|
||||||
}
|
}
|
||||||
Some((ValueMatch::F64(ref e), ref matched))
|
Some((ValueMatch::F64(ref e), ref matched)) if (value - *e).abs() < f64::EPSILON => {
|
||||||
if (value - *e).abs() < f64::EPSILON =>
|
|
||||||
{
|
|
||||||
matched.store(true, Release);
|
matched.store(true, Release);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@ -576,6 +577,8 @@ impl Visit for MatchVisitor<'_> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use alloc::format;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
|
6
tracing-subscriber/src/filter/env/mod.rs
vendored
6
tracing-subscriber/src/filter/env/mod.rs
vendored
@ -14,8 +14,10 @@ use crate::{
|
|||||||
layer::{Context, Layer},
|
layer::{Context, Layer},
|
||||||
sync::RwLock,
|
sync::RwLock,
|
||||||
};
|
};
|
||||||
|
use alloc::{fmt, str::FromStr, vec::Vec};
|
||||||
|
use core::cell::RefCell;
|
||||||
use directive::ParseError;
|
use directive::ParseError;
|
||||||
use std::{cell::RefCell, collections::HashMap, env, error::Error, fmt, str::FromStr};
|
use std::{collections::HashMap, env, error::Error};
|
||||||
use thread_local::ThreadLocal;
|
use thread_local::ThreadLocal;
|
||||||
use tracing_core::{
|
use tracing_core::{
|
||||||
callsite,
|
callsite,
|
||||||
@ -835,6 +837,8 @@ impl Error for FromEnvError {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use alloc::format;
|
||||||
|
use std::println;
|
||||||
use tracing_core::field::FieldSet;
|
use tracing_core::field::FieldSet;
|
||||||
use tracing_core::*;
|
use tracing_core::*;
|
||||||
|
|
||||||
|
@ -32,15 +32,14 @@ use crate::{
|
|||||||
layer::{self, Context, Layer},
|
layer::{self, Context, Layer},
|
||||||
registry,
|
registry,
|
||||||
};
|
};
|
||||||
use std::{
|
use alloc::{boxed::Box, fmt, sync::Arc};
|
||||||
|
use core::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
fmt,
|
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
sync::Arc,
|
|
||||||
thread_local,
|
|
||||||
};
|
};
|
||||||
|
use std::thread_local;
|
||||||
use tracing_core::{
|
use tracing_core::{
|
||||||
span,
|
span,
|
||||||
subscriber::{Interest, Subscriber},
|
subscriber::{Interest, Subscriber},
|
||||||
|
@ -13,7 +13,6 @@ use crate::{
|
|||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
};
|
};
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use core::{
|
use core::{
|
||||||
fmt,
|
fmt,
|
||||||
@ -596,16 +595,17 @@ impl<'a> Iterator for Iter<'a> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use alloc::{string::ToString, vec, vec::Vec};
|
||||||
feature! {
|
#[cfg(feature = "std")]
|
||||||
#![not(feature = "std")]
|
use std::dbg;
|
||||||
use alloc::{vec, vec::Vec, string::ToString};
|
|
||||||
|
|
||||||
// `dbg!` is only available with `libstd`; just nop it out when testing
|
// `dbg!` is only available with `libstd`; just nop it out when testing
|
||||||
// with alloc only.
|
// with alloc only.
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
macro_rules! dbg {
|
macro_rules! dbg {
|
||||||
($x:expr) => { $x }
|
($x:expr) => {
|
||||||
}
|
$x
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expect_parse(s: &str) -> Targets {
|
fn expect_parse(s: &str) -> Targets {
|
||||||
@ -775,6 +775,8 @@ mod tests {
|
|||||||
// `println!` is only available with `libstd`.
|
// `println!` is only available with `libstd`.
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
fn size_of_filters() {
|
fn size_of_filters() {
|
||||||
|
use std::println;
|
||||||
|
|
||||||
fn print_sz(s: &str) {
|
fn print_sz(s: &str) {
|
||||||
let filter = s.parse::<Targets>().expect("filter should parse");
|
let filter = s.parse::<Targets>().expect("filter should parse");
|
||||||
println!(
|
println!(
|
||||||
|
@ -4,10 +4,10 @@ use crate::{
|
|||||||
layer::{self, Context},
|
layer::{self, Context},
|
||||||
registry::{self, LookupSpan, SpanRef},
|
registry::{self, LookupSpan, SpanRef},
|
||||||
};
|
};
|
||||||
|
use alloc::{fmt, format, string::String};
|
||||||
|
use core::{any::TypeId, marker::PhantomData, ops::Deref};
|
||||||
use format::{FmtSpan, TimingDisplay};
|
use format::{FmtSpan, TimingDisplay};
|
||||||
use std::{
|
use std::{cell::RefCell, env, eprintln, io, thread_local, time::Instant};
|
||||||
any::TypeId, cell::RefCell, env, fmt, io, marker::PhantomData, ops::Deref, time::Instant,
|
|
||||||
};
|
|
||||||
use tracing_core::{
|
use tracing_core::{
|
||||||
field,
|
field,
|
||||||
span::{Attributes, Current, Id, Record},
|
span::{Attributes, Current, Id, Record},
|
||||||
@ -1257,6 +1257,7 @@ mod test {
|
|||||||
time,
|
time,
|
||||||
};
|
};
|
||||||
use crate::Registry;
|
use crate::Registry;
|
||||||
|
use alloc::{string::ToString, vec, vec::Vec};
|
||||||
use format::FmtSpan;
|
use format::FmtSpan;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use tracing::subscriber::with_default;
|
use tracing::subscriber::with_default;
|
||||||
@ -1631,8 +1632,7 @@ mod test {
|
|||||||
.with_timer(MockTime)
|
.with_timer(MockTime)
|
||||||
.with_span_events(FmtSpan::ACTIVE);
|
.with_span_events(FmtSpan::ACTIVE);
|
||||||
|
|
||||||
let (reloadable_layer, reload_handle) =
|
let (reloadable_layer, reload_handle) = crate::reload::Layer::new(inner_layer);
|
||||||
crate::reload::Layer::new(inner_layer);
|
|
||||||
let reload = reloadable_layer.with_subscriber(Registry::default());
|
let reload = reloadable_layer.with_subscriber(Registry::default());
|
||||||
|
|
||||||
with_default(reload, || {
|
with_default(reload, || {
|
||||||
|
@ -7,12 +7,14 @@ use crate::{
|
|||||||
},
|
},
|
||||||
registry::LookupSpan,
|
registry::LookupSpan,
|
||||||
};
|
};
|
||||||
use serde::ser::{SerializeMap, Serializer as _};
|
use alloc::{
|
||||||
use serde_json::Serializer;
|
|
||||||
use std::{
|
|
||||||
collections::BTreeMap,
|
collections::BTreeMap,
|
||||||
fmt::{self, Write},
|
fmt::{self, Write},
|
||||||
|
format,
|
||||||
|
string::String,
|
||||||
};
|
};
|
||||||
|
use serde::ser::{SerializeMap, Serializer as _};
|
||||||
|
use serde_json::Serializer;
|
||||||
use tracing_core::{
|
use tracing_core::{
|
||||||
field::{self, Field},
|
field::{self, Field},
|
||||||
span::Record,
|
span::Record,
|
||||||
|
@ -48,7 +48,6 @@ use tracing_log::NormalizeEvent;
|
|||||||
#[cfg(feature = "ansi")]
|
#[cfg(feature = "ansi")]
|
||||||
use nu_ansi_term::{Color, Style};
|
use nu_ansi_term::{Color, Style};
|
||||||
|
|
||||||
|
|
||||||
mod escape;
|
mod escape;
|
||||||
use escape::Escape;
|
use escape::Escape;
|
||||||
|
|
||||||
@ -433,6 +432,8 @@ impl<'writer> Writer<'writer> {
|
|||||||
/// value implementing [`fmt::Write`] is a [`String`], it will contain
|
/// value implementing [`fmt::Write`] is a [`String`], it will contain
|
||||||
/// the formatted output of [`Format::format_event`], which may then be
|
/// the formatted output of [`Format::format_event`], which may then be
|
||||||
/// used for other purposes.
|
/// used for other purposes.
|
||||||
|
///
|
||||||
|
/// [`String`]: alloc::string::String
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(writer: &'writer mut impl fmt::Write) -> Self {
|
pub fn new(writer: &'writer mut impl fmt::Write) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -1269,7 +1270,10 @@ impl field::Visit for DefaultVisitor<'_> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
self.record_debug(field, &format_args!("{}", Escape(&format_args!("{}", value))))
|
self.record_debug(
|
||||||
|
field,
|
||||||
|
&format_args!("{}", Escape(&format_args!("{}", value))),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1294,7 +1298,7 @@ impl field::Visit for DefaultVisitor<'_> {
|
|||||||
"message" => {
|
"message" => {
|
||||||
// Escape ANSI characters to prevent malicious patterns (e.g., terminal injection attacks)
|
// Escape ANSI characters to prevent malicious patterns (e.g., terminal injection attacks)
|
||||||
write!(self.writer, "{:?}", Escape(value))
|
write!(self.writer, "{:?}", Escape(value))
|
||||||
},
|
}
|
||||||
name if name.starts_with("r#") => write!(
|
name if name.starts_with("r#") => write!(
|
||||||
self.writer,
|
self.writer,
|
||||||
"{}{}{:?}",
|
"{}{}{:?}",
|
||||||
@ -1750,6 +1754,11 @@ impl Display for TimingDisplay {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(super) mod test {
|
pub(super) mod test {
|
||||||
use crate::fmt::{test::MockMakeWriter, time::FormatTime};
|
use crate::fmt::{test::MockMakeWriter, time::FormatTime};
|
||||||
|
use alloc::{
|
||||||
|
borrow::ToOwned,
|
||||||
|
format,
|
||||||
|
string::{String, ToString},
|
||||||
|
};
|
||||||
use tracing::{
|
use tracing::{
|
||||||
self,
|
self,
|
||||||
dispatcher::{set_default, Dispatch},
|
dispatcher::{set_default, Dispatch},
|
||||||
|
@ -189,7 +189,10 @@
|
|||||||
//! https://docs.rs/tracing/latest/tracing/trait.Subscriber.html
|
//! https://docs.rs/tracing/latest/tracing/trait.Subscriber.html
|
||||||
//! [`tracing`]: https://crates.io/crates/tracing
|
//! [`tracing`]: https://crates.io/crates/tracing
|
||||||
//! [`fmt::format`]: mod@crate::fmt::format
|
//! [`fmt::format`]: mod@crate::fmt::format
|
||||||
use std::{any::TypeId, error::Error, io};
|
|
||||||
|
use alloc::boxed::Box;
|
||||||
|
use core::any::TypeId;
|
||||||
|
use std::{error::Error, io};
|
||||||
use tracing_core::{span, subscriber::Interest, Event, Metadata};
|
use tracing_core::{span, subscriber::Interest, Event, Metadata};
|
||||||
|
|
||||||
mod fmt_layer;
|
mod fmt_layer;
|
||||||
@ -1196,7 +1199,7 @@ pub fn try_init() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
|
|||||||
#[cfg(not(feature = "env-filter"))]
|
#[cfg(not(feature = "env-filter"))]
|
||||||
let subscriber = {
|
let subscriber = {
|
||||||
use crate::{filter::Targets, layer::SubscriberExt};
|
use crate::{filter::Targets, layer::SubscriberExt};
|
||||||
use std::{env, str::FromStr};
|
use std::{env, eprintln, str::FromStr};
|
||||||
let targets = match env::var("RUST_LOG") {
|
let targets = match env::var("RUST_LOG") {
|
||||||
Ok(var) => Targets::from_str(&var)
|
Ok(var) => Targets::from_str(&var)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
@ -1255,6 +1258,7 @@ mod test {
|
|||||||
Subscriber,
|
Subscriber,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use alloc::{borrow::ToOwned, string::String, vec::Vec};
|
||||||
use std::{
|
use std::{
|
||||||
io,
|
io,
|
||||||
sync::{Arc, Mutex, MutexGuard, TryLockError},
|
sync::{Arc, Mutex, MutexGuard, TryLockError},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::fmt::format::Writer;
|
use crate::fmt::format::Writer;
|
||||||
use crate::fmt::time::FormatTime;
|
use crate::fmt::time::FormatTime;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use alloc::{format, string::String, sync::Arc};
|
||||||
|
|
||||||
/// Formats [local time]s and [UTC time]s with `FormatTime` implementations
|
/// Formats [local time]s and [UTC time]s with `FormatTime` implementations
|
||||||
/// that use the [`chrono` crate].
|
/// that use the [`chrono` crate].
|
||||||
@ -108,8 +108,7 @@ impl FormatTime for ChronoUtc {
|
|||||||
/// the supported syntax.
|
/// the supported syntax.
|
||||||
///
|
///
|
||||||
/// [`chrono::format::strftime`]: https://docs.rs/chrono/0.4.9/chrono/format/strftime/index.html
|
/// [`chrono::format::strftime`]: https://docs.rs/chrono/0.4.9/chrono/format/strftime/index.html
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq, Default)]
|
||||||
#[derive(Default)]
|
|
||||||
enum ChronoFmtType {
|
enum ChronoFmtType {
|
||||||
/// Format according to the RFC 3339 convention.
|
/// Format according to the RFC 3339 convention.
|
||||||
#[default]
|
#[default]
|
||||||
@ -118,13 +117,12 @@ enum ChronoFmtType {
|
|||||||
Custom(String),
|
Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::fmt::format::Writer;
|
use crate::fmt::format::Writer;
|
||||||
use crate::fmt::time::FormatTime;
|
use crate::fmt::time::FormatTime;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use alloc::{borrow::ToOwned, string::String, sync::Arc};
|
||||||
|
|
||||||
use super::ChronoFmtType;
|
use super::ChronoFmtType;
|
||||||
use super::ChronoLocal;
|
use super::ChronoLocal;
|
||||||
|
@ -192,7 +192,6 @@
|
|||||||
// permissive licensing, and of not having licensing issues being an
|
// permissive licensing, and of not having licensing issues being an
|
||||||
// obstacle to adoption, that text has been removed.
|
// obstacle to adoption, that text has been removed.
|
||||||
|
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
/// A date/time type which exists primarily to convert `SystemTime` timestamps into an ISO 8601
|
/// A date/time type which exists primarily to convert `SystemTime` timestamps into an ISO 8601
|
||||||
@ -333,7 +332,10 @@ impl From<std::time::SystemTime> for DateTime {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use i32;
|
use i32;
|
||||||
use std::time::{Duration, UNIX_EPOCH};
|
use std::{
|
||||||
|
format,
|
||||||
|
time::{Duration, UNIX_EPOCH},
|
||||||
|
};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
//! Abstractions for creating [`io::Write`] instances.
|
//! Abstractions for creating [`io::Write`] instances.
|
||||||
//!
|
//!
|
||||||
//! [`io::Write`]: std::io::Write
|
//! [`io::Write`]: std::io::Write
|
||||||
|
|
||||||
|
use alloc::{boxed::Box, fmt, string::String, sync::Arc};
|
||||||
use std::{
|
use std::{
|
||||||
fmt,
|
eprint,
|
||||||
io::{self, Write},
|
io::{self, Write},
|
||||||
sync::{Arc, Mutex, MutexGuard},
|
print,
|
||||||
|
sync::{Mutex, MutexGuard},
|
||||||
};
|
};
|
||||||
use tracing_core::Metadata;
|
use tracing_core::Metadata;
|
||||||
|
|
||||||
@ -715,9 +718,7 @@ impl TestWriter {
|
|||||||
|
|
||||||
/// Returns a new `TestWriter` that writes to `stderr` instead of `stdout`.
|
/// Returns a new `TestWriter` that writes to `stderr` instead of `stdout`.
|
||||||
pub fn with_stderr() -> Self {
|
pub fn with_stderr() -> Self {
|
||||||
Self {
|
Self { use_stderr: true }
|
||||||
use_stderr: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1224,8 +1225,10 @@ mod test {
|
|||||||
use crate::fmt::format::Format;
|
use crate::fmt::format::Format;
|
||||||
use crate::fmt::test::{MockMakeWriter, MockWriter};
|
use crate::fmt::test::{MockMakeWriter, MockWriter};
|
||||||
use crate::fmt::Subscriber;
|
use crate::fmt::Subscriber;
|
||||||
|
use alloc::vec::Vec;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::{dbg, format, println};
|
||||||
use tracing::{debug, error, info, trace, warn, Level};
|
use tracing::{debug, error, info, trace, warn, Level};
|
||||||
use tracing_core::dispatcher::{self, Dispatch};
|
use tracing_core::dispatcher::{self, Dispatch};
|
||||||
|
|
||||||
|
@ -1675,7 +1675,6 @@ where
|
|||||||
|
|
||||||
feature! {
|
feature! {
|
||||||
#![any(feature = "std", feature = "alloc")]
|
#![any(feature = "std", feature = "alloc")]
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
macro_rules! layer_impl_body {
|
macro_rules! layer_impl_body {
|
||||||
@ -1773,8 +1772,6 @@ feature! {
|
|||||||
layer_impl_body! {}
|
layer_impl_body! {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
impl<S, L> Layer<S> for Vec<L>
|
impl<S, L> Layer<S> for Vec<L>
|
||||||
where
|
where
|
||||||
L: Layer<S>,
|
L: Layer<S>,
|
||||||
|
@ -113,6 +113,8 @@ fn downcasts_to_layer() {
|
|||||||
|
|
||||||
#[cfg(all(feature = "registry", feature = "std"))]
|
#[cfg(all(feature = "registry", feature = "std"))]
|
||||||
mod registry_tests {
|
mod registry_tests {
|
||||||
|
use std::dbg;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::registry::LookupSpan;
|
use crate::registry::LookupSpan;
|
||||||
|
|
||||||
|
@ -161,6 +161,8 @@
|
|||||||
//! [`time` crate]: https://crates.io/crates/time
|
//! [`time` crate]: https://crates.io/crates/time
|
||||||
//! [`liballoc`]: https://doc.rust-lang.org/alloc/index.html
|
//! [`liballoc`]: https://doc.rust-lang.org/alloc/index.html
|
||||||
//! [`libstd`]: https://doc.rust-lang.org/std/index.html
|
//! [`libstd`]: https://doc.rust-lang.org/std/index.html
|
||||||
|
|
||||||
|
#![no_std]
|
||||||
#![doc(
|
#![doc(
|
||||||
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png",
|
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png",
|
||||||
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
|
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
|
||||||
@ -201,10 +203,11 @@
|
|||||||
// future, reducing diff noise. Allow this even though clippy considers it
|
// future, reducing diff noise. Allow this even though clippy considers it
|
||||||
// "needless".
|
// "needless".
|
||||||
#![allow(clippy::needless_update)]
|
#![allow(clippy::needless_update)]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
extern crate std;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// taken from https://github.com/hyperium/http/blob/master/src/extensions.rs.
|
// taken from https://github.com/hyperium/http/blob/master/src/extensions.rs.
|
||||||
|
|
||||||
use crate::sync::{RwLockReadGuard, RwLockWriteGuard};
|
use crate::sync::{RwLockReadGuard, RwLockWriteGuard};
|
||||||
use std::{
|
use alloc::{boxed::Box, fmt};
|
||||||
|
use core::{
|
||||||
any::{Any, TypeId},
|
any::{Any, TypeId},
|
||||||
collections::HashMap,
|
|
||||||
fmt,
|
|
||||||
hash::{BuildHasherDefault, Hasher},
|
hash::{BuildHasherDefault, Hasher},
|
||||||
};
|
};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[allow(warnings)]
|
#[allow(warnings)]
|
||||||
type AnyMap = HashMap<TypeId, Box<dyn Any + Send + Sync>, BuildHasherDefault<IdHasher>>;
|
type AnyMap = HashMap<TypeId, Box<dyn Any + Send + Sync>, BuildHasherDefault<IdHasher>>;
|
||||||
|
@ -519,7 +519,10 @@ mod tests {
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
registry::LookupSpan,
|
registry::LookupSpan,
|
||||||
};
|
};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::{
|
||||||
|
sync::{Arc, Mutex},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use tracing::{span, Subscriber};
|
use tracing::{span, Subscriber};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -10,10 +10,11 @@ use crate::{
|
|||||||
},
|
},
|
||||||
sync::RwLock,
|
sync::RwLock,
|
||||||
};
|
};
|
||||||
use std::{
|
use core::{
|
||||||
cell::{self, Cell, RefCell},
|
cell::{self, Cell, RefCell},
|
||||||
sync::atomic::{fence, AtomicUsize, Ordering},
|
sync::atomic::{fence, AtomicUsize, Ordering},
|
||||||
};
|
};
|
||||||
|
use std::thread_local;
|
||||||
use tracing_core::{
|
use tracing_core::{
|
||||||
dispatcher::{self, Dispatch},
|
dispatcher::{self, Dispatch},
|
||||||
span::{self, Current, Id},
|
span::{self, Current, Id},
|
||||||
@ -536,7 +537,9 @@ mod tests {
|
|||||||
use crate::{layer::Context, registry::LookupSpan, Layer};
|
use crate::{layer::Context, registry::LookupSpan, Layer};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
dbg, println,
|
||||||
sync::{Arc, Mutex, Weak},
|
sync::{Arc, Mutex, Weak},
|
||||||
|
vec::Vec,
|
||||||
};
|
};
|
||||||
use tracing::{self, subscriber::with_default};
|
use tracing::{self, subscriber::with_default};
|
||||||
use tracing_core::{
|
use tracing_core::{
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use alloc::vec::Vec;
|
||||||
pub(crate) use tracing_core::span::Id;
|
pub(crate) use tracing_core::span::Id;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
//! Extension traits and other utilities to make working with subscribers more
|
//! Extension traits and other utilities to make working with subscribers more
|
||||||
//! ergonomic.
|
//! ergonomic.
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
use alloc::boxed::Box;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user