File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
tracing-subscriber/src/filter/env Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ impl FromStr for Directive {
181181 ^(?P<global_level>trace|TRACE|debug|DEBUG|info|INFO|warn|WARN|error|ERROR|off|OFF|[0-5])$ |
182182 ^
183183 (?: # target name or span name
184- (?P<target>[\w:]+)|(?P<span>\[[^\]]*\])
184+ (?P<target>[\w:- ]+)|(?P<span>\[[^\]]*\])
185185 ){1,2}
186186 (?: # level or nothing
187187 =(?P<level>trace|TRACE|debug|DEBUG|info|INFO|warn|WARN|error|ERROR|off|OFF|[0-5])?
@@ -1019,4 +1019,13 @@ mod test {
10191019 assert_eq ! ( dirs[ 2 ] . level, LevelFilter :: DEBUG ) ;
10201020 assert_eq ! ( dirs[ 2 ] . in_span, Some ( "baz" . to_string( ) ) ) ;
10211021 }
1022+
1023+ #[ test]
1024+ fn parse_directives_with_dash_in_target_name ( ) {
1025+ let dirs = parse_directives ( "target-name=info" ) ;
1026+ assert_eq ! ( dirs. len( ) , 1 , "\n parsed: {:#?}" , dirs) ;
1027+ assert_eq ! ( dirs[ 0 ] . target, Some ( "target-name" . to_string( ) ) ) ;
1028+ assert_eq ! ( dirs[ 0 ] . level, LevelFilter :: INFO ) ;
1029+ assert_eq ! ( dirs[ 0 ] . in_span, None ) ;
1030+ }
10221031}
Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ use tracing_core::{
6868/// - If only a level is provided, it will set the maximum level for all `Span`s and `Event`s
6969/// that are not enabled by other filters.
7070/// - A directive without a level will enable anything that it matches. This is equivalent to `=trace`.
71+ /// - When a crate has a dash in its name, the default target for events will be the
72+ /// crate's module path as it appears in Rust. This means every dash will be replaced
73+ /// with an underscore.
74+ /// - A dash in a target will only appear when being specified explicitly:
75+ /// `tracing::info!(target: "target-name", ...);`
7176///
7277/// ## Examples
7378///
You can’t perform that action at this time.
0 commit comments