-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hi Guys, I found this repository linked on a similar issue on EnvFilter (tokio-rs/tracing#1181), so I thought I'd give it a try.
I am trying to do log filtering based off a field=value, but I cannot get any logs to match when value is present. I'll put a few examples below to show:
let filter = Filter::parse(FILTER_STRING);
println!("{:?}", &filter);
registry
.with(
fmt::Layer::new()
.with_filter(filter),
)
.try_init()
.expect("Failed to set subscriber");
// More code here ...
// Note that data.id() is not a string, but it has a plain string debug representation
tracing::trace!(device_id=?data.id(), "Test trace");
// More code here ...FILTER_STRING = info,[{device_id}]
Filter debug representation
Filter { scope: ThreadLocal { local_data: None }, statics: DirectiveSet { directives: [StaticDirective { target: None, fields: ["device_id"], level: LevelFilter::TRACE }, StaticDirective { target: None, fields: [], level: LevelFilter::INFO }], level: LevelFilter::TRACE }, dynamics: DirectiveSet { directives: [DynamicDirective { span: None, fields: [FieldMatch { name: "device_id", value: None }], target: None, level: LevelFilter::TRACE }], level: LevelFilter::TRACE }, by_cs: RwLock { data: {}, poisoned: false, .. } }
2022-11-10T21:45:53.909619Z TRACE handle_device_data: test_project::test: Test trace device_id=ac233fa8c59b
FILTER_STRING = info,[{device_id=.*}]
Filter debug representation
Filter { scope: ThreadLocal { local_data: None }, statics: DirectiveSet { directives: [StaticDirective { target: None, fields: [], level: LevelFilter::INFO }], level: LevelFilter::INFO }, dynamics: DirectiveSet { directives: [DynamicDirective { span: None, fields: [FieldMatch { name: "device_id", value: Some(Pat(PatternMatch { matcher: Pattern { automaton: PremultipliedByteClass(PremultipliedByteClass(DenseDFA(
D 000000:
>*000016: \x00 => 16, \x02 => 16, \x07 => 32, \x08 => 48, \t => 64, \n => 80, \x0b => 64, \x0c => 96, \r => 112, \x0e => 128
000032: \x03-\x05 => 16
000048: \x05 => 32
000064: \x03-\x05 => 32
000080: \x03-\x04 => 32
000096: \x04-\x05 => 64
000112: \x03-\x05 => 64
000128: \x03 => 64
)
)) }, pattern: ".*" })) }], target: None, level: LevelFilter::TRACE }], level: LevelFilter::TRACE }, by_cs: RwLock { data: {}, poisoned: false, .. } }
*** NO MORE LOGS matching device_id=*
FILTER_STRING = info,[{device_id=ac233fa8c59b}]
Filter debug representation
Filter { scope: ThreadLocal { local_data: None }, statics: DirectiveSet { directives: [StaticDirective { target: None, fields: [], level: LevelFilter::INFO }], level: LevelFilter::INFO }, dynamics: DirectiveSet { directives: [DynamicDirective { span: None, fields: [FieldMatch { name: "device_id", value: Some(Pat(PatternMatch { matcher: Pattern { automaton: PremultipliedByteClass(PremultipliedByteClass(DenseDFA(
D 000000:
*000028:
000056: \x00-\x08 => 560, \t => 56, \n => 560, \x0b => 280, \x0c-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000084: \x0f-\x11 => 560
000112: \x11 => 84
000140: \x0f-\x11 => 84
000168: \x0f-\x10 => 84
000196: \x10-\x11 => 140
000224: \x0f-\x11 => 140
000252: \x0f => 140
000280: \x00 => 560, \x01 => 308, \x02-\x08 => 560, \t => 56, \n-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000308: \x00-\x01 => 560, \x02 => 336, \x03-\x08 => 560, \t => 56, \n-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000336: \x00-\x01 => 560, \x02 => 364, \x03-\x08 => 560, \t => 56, \n-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000364: \x00-\x08 => 560, \t => 56, \n-\x0c => 560, \r => 392, \x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000392: \x00-\x08 => 560, \t => 420, \n-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000420: \x00-\x05 => 560, \x06 => 448, \x07-\x08 => 560, \t => 56, \n => 560, \x0b => 280, \x0c-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000448: \x00-\x08 => 560, \t => 56, \n => 560, \x0b => 476, \x0c-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000476: \x00-\x03 => 560, \x04 => 504, \x05-\x08 => 560, \t => 56, \n-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000504: \x00-\x06 => 560, \x07 => 532, \x08 => 560, \t => 56, \n-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
000532: \x00-\x05 => 560, \x06 => 28, \x07-\x08 => 560, \t => 56, \n-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
> 000560: \x00-\x08 => 560, \t => 56, \n-\x0e => 560, \x13 => 84, \x14 => 112, \x15 => 140, \x16 => 168, \x17 => 140, \x18 => 196, \x19 => 224, \x1a => 252
)
)) }, pattern: "ac233fa8c598" })) }], target: None, level: LevelFilter::TRACE }], level: LevelFilter::TRACE }, by_cs: RwLock { data: {}, poisoned: false, .. } }
*** NO MORE LOGS matching device_id=*
Metadata
Metadata
Assignees
Labels
No labels