kerf 0.1.2

Simple tokio-based trace event collector
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
<!-- Generated at 2025-10-07 11:42:51 UTC -->


# Crate `kerf` Module Structure

```
kerf
└── src (9 mod)
    ├── config (2 struct: Config, Tab, 1 trait: IntoTracerTab)
    ├── dispatcher (1 struct: ResultSender, 1 type: TabCallback)
    ├── env_config (1 fn: parse_level, 2 struct: EnvConfig, TuiConfig, 1 enum: OutputFormat)
    ├── event (2 struct: Event, EventMessageVisitor, 2 type: ArcEvent, TraceEventId)
    ├── kerf (2 struct: Kerf, KerfBuilder, 3 type: DroppedEventCallback, EventCallback, SilencedEventCallback)
    ├── lib
    ├── matcher (1 fn: matches, 4 struct: Level, Match, MatcherSet, SerializableMatch, 1 enum: PatternMatcher, 1 trait: IntoMatcherSet)
    ├── stats (10 struct: AtomicCounter, Location, LocationStats, ModuleStats, StatEntry, StatEntrySnapshot, StatKey, StatsConfig, StatsSnapshot, StatsTracker, 1 enum: EventType)
    └── tracing_subscriber (1 struct: TracingSubscriber)
```

# Root `kerf` Module
## [`type EventCallback`]src/kerf.rs#L17

`type EventCallback = ...;`

## [`type SilencedEventCallback`]src/kerf.rs#L18

`type SilencedEventCallback = ...;`

## [`type DroppedEventCallback`]src/kerf.rs#L19

`type DroppedEventCallback = ...;`

## [`struct Kerf`]src/kerf.rs#L22

### [`Kerf::init_default`]src/kerf.rs#L29

Initialize tracing with default configuration

`fn() -> Result<Self>`

### [`Kerf::init`]src/kerf.rs#L34

Initialize tracing with the provided config

`fn(config: Config) -> Result<Self>`

### [`Kerf::set_stdout_callback`]src/kerf.rs#L70

`fn(self: &Self) -> Result<()>`

### [`Kerf::set_tmpfile_callback`]src/kerf.rs#L84

`fn(self: &Self) -> Result<PathBuf>`

### [`Kerf::set_callback`]src/kerf.rs#L138

Set a callback for handling captured trace events

`fn(self: &Self, callback: F) -> Result<oneshot::Receiver<Result<()>>>`

### [`Kerf::add_tab`]src/kerf.rs#L154

Add a new tab

`fn(self: &Self, name: impl Into<String>, matcher_set: MatcherSet) -> Result<oneshot::Receiver<Result<()>>>`

### [`Kerf::set_silenced_callback`]src/kerf.rs#L173

`fn(self: &Self, callback: F) -> Result<oneshot::Receiver<Result<()>>>`

### [`Kerf::set_dropped_callback`]src/kerf.rs#L191

`fn(self: &Self, callback: F) -> Result<oneshot::Receiver<Result<()>>>`

### [`Kerf::update_tab`]src/kerf.rs#L210

Update an existing tab's filter set

`fn(self: &Self, name: impl Into<String>, matcher_set: MatcherSet) -> Result<oneshot::Receiver<Result<()>>>`

### [`Kerf::remove_tab`]src/kerf.rs#L230

Remove a tab by name

`fn(self: &Self, name: impl Into<String>) -> Result<oneshot::Receiver<Result<()>>>`

### [`Kerf::get_stats`]src/kerf.rs#L242

Get stats snapshot if stats are enabled

`fn(self: &Self) -> Result<oneshot::Receiver<Option<StatsSnapshot>>>`

### [`Kerf::clear_stats`]src/kerf.rs#L253

Clear stats if enabled

`fn(self: &Self) -> Result<oneshot::Receiver<Result<()>>>`

### [`Kerf::with_tab_callback`]src/kerf.rs#L265

Set a callback for a specific tab (builder pattern)

`fn(self: Self, tab_name: impl Into<String>, callback: F) -> KerfBuilder`

### [`Kerf::set_tab_callback`]src/kerf.rs#L329

Set a callback for a specific tab (direct method)

`async fn(self: &Self, tab_name: impl Into<String>, callback: F) -> Result<()>`

### [`Kerf::remove_tab_callback`]src/kerf.rs#L340

Remove a callback for a specific tab

`async fn(self: &Self, tab_name: impl Into<String>) -> Result<()>`

## [`struct KerfBuilder`]src/kerf.rs#L275

Builder for configuring per-tab callbacks

### [`KerfBuilder::with_tab_callback`]src/kerf.rs#L288

Add a callback for a specific tab

`fn(self: Self, tab_name: impl Into<String>, callback: F) -> Self`

### [`KerfBuilder::build`]src/kerf.rs#L298

Build and register all callbacks

`async fn(self: Self) -> Result<Kerf>`

## [`type TraceEventId`]src/event.rs#L14

`type TraceEventId = ...;`

## [`struct Event`]src/event.rs#L17

### [`Event::new`]src/event.rs#L34

`fn(id: u64, tracing_event: &tracing::Event<'_>) -> Self`

### [`Event::into_shared`]src/event.rs#L57

`fn(self: Self) -> Arc<Self>`

### [`Event::ref_count`]src/event.rs#L61

`fn(self: &Arc<Self>) -> usize`

### [`Event::ptr_eq`]src/event.rs#L65

`fn(self: &Arc<Self>, other: &Arc<Self>) -> bool`

### [`Event::format`]src/event.rs#L69

`fn(self: &Self) -> String`

### [`Event::format_with_file`]src/event.rs#L90

`fn(self: &Self) -> String`

### [`Event::format_with_span_hierarchy`]src/event.rs#L100

`fn(self: &Self) -> String`

### [`Event::format_with_fields`]src/event.rs#L110

`fn(self: &Self) -> String`

### [`Event::format_full`]src/event.rs#L128

`fn(self: &Self) -> String`

### [`Event::format_colored`]src/event.rs#L215

Format with colors using ANSI escape codes

`fn(self: &Self) -> String`

### [`Event::format_colored_with_file`]src/event.rs#L242

Format with colors and file info

`fn(self: &Self) -> String`

### [`Event::format_colored_with_span_hierarchy`]src/event.rs#L259

Format with colors, file info, and span hierarchy

`fn(self: &Self) -> String`

### [`Event::format_colored_with_fields`]src/event.rs#L273

Format with colors and fields

`fn(self: &Self) -> String`

### [`Event::format_colored_full`]src/event.rs#L298

Full colored format with all information

`fn(self: &Self) -> String`

### [`Event::format_colored_multiline`]src/event.rs#L348

Advanced colored format with multiline support

`fn(self: &Self) -> Vec<String>`

## [`type ArcEvent`]src/event.rs#L32

`type ArcEvent = ...;`

## [`struct EventMessageVisitor`]src/event.rs#L159

## [`enum PatternMatcher`]src/matcher.rs#L18

### [`PatternMatcher::new`]src/matcher.rs#L27

`fn(pattern: &str) -> Self`

### [`PatternMatcher::matches`]src/matcher.rs#L76

`fn(self: &Self, value: &str) -> bool`

## [`struct Level`]src/matcher.rs#L138

### [`Level::is_trace`]src/matcher.rs#L160

`fn(self: &Self) -> bool`

### [`Level::is_error`]src/matcher.rs#L163

`fn(self: &Self) -> bool`

### [`Level::is_warn`]src/matcher.rs#L166

`fn(self: &Self) -> bool`

### [`Level::is_info`]src/matcher.rs#L169

`fn(self: &Self) -> bool`

### [`Level::is_debug`]src/matcher.rs#L172

`fn(self: &Self) -> bool`

## [`struct Match`]src/matcher.rs#L257

### [`Match::new`]src/matcher.rs#L384

`fn(level: impl Into<Level>) -> Self`

### [`Match::trace`]src/matcher.rs#L399

`fn() -> Self`

### [`Match::debug`]src/matcher.rs#L403

`fn() -> Self`

### [`Match::info`]src/matcher.rs#L407

`fn() -> Self`

### [`Match::warn`]src/matcher.rs#L411

`fn() -> Self`

### [`Match::error`]src/matcher.rs#L415

`fn() -> Self`

### [`Match::include`]src/matcher.rs#L420

`fn(self: Self) -> Self`

### [`Match::exclude`]src/matcher.rs#L425

`fn(self: Self) -> Self`

### [`Match::module_patterns`]src/matcher.rs#L430

`fn(self: Self, patterns: impl IntoIterator<Item = impl Into<String>>) -> Self`

### [`Match::module_pattern`]src/matcher.rs#L443

`fn(self: Self, pattern: impl Into<String>) -> Self`

### [`Match::extend_module_patterns`]src/matcher.rs#L450

`fn(self: Self, patterns: impl IntoIterator<Item = impl Into<String>>) -> Self`

### [`Match::file_patterns`]src/matcher.rs#L462

`fn(self: Self, patterns: impl IntoIterator<Item = impl Into<String>>) -> Self`

### [`Match::file_pattern`]src/matcher.rs#L472

`fn(self: Self, pattern: impl Into<String>) -> Self`

### [`Match::extend_file_patterns`]src/matcher.rs#L479

`fn(self: Self, patterns: impl IntoIterator<Item = impl Into<String>>) -> Self`

### [`Match::span_patterns`]src/matcher.rs#L491

`fn(self: Self, patterns: impl IntoIterator<Item = impl Into<String>>) -> Self`

### [`Match::span_pattern`]src/matcher.rs#L501

`fn(self: Self, pattern: impl Into<String>) -> Self`

### [`Match::extend_span_patterns`]src/matcher.rs#L508

`fn(self: Self, patterns: impl IntoIterator<Item = impl Into<String>>) -> Self`

### [`Match::target_patterns`]src/matcher.rs#L520

`fn(self: Self, patterns: impl IntoIterator<Item = impl Into<String>>) -> Self`

### [`Match::target_pattern`]src/matcher.rs#L533

`fn(self: Self, pattern: impl Into<String>) -> Self`

### [`Match::extend_target_patterns`]src/matcher.rs#L540

`fn(self: Self, patterns: impl IntoIterator<Item = impl Into<String>>) -> Self`

### [`Match::all_modules`]src/matcher.rs#L553

`fn(self: Self) -> Self`

### [`Match::into_matcher_set`]src/matcher.rs#L560

`fn(self: Self) -> MatcherSet`

### [`Match::matches`]src/matcher.rs#L564

`fn(self: &Self, event: &Event) -> bool`

## [`struct SerializableMatch`]src/matcher.rs#L273

## [`struct MatcherSet`]src/matcher.rs#L678

### [`MatcherSet::empty`]src/matcher.rs#L722

`fn() -> Self`

### [`MatcherSet::from_matcher`]src/matcher.rs#L728

`fn(matcher: Match) -> Self`

### [`MatcherSet::from_matchers`]src/matcher.rs#L734

`fn(matchers: impl IntoIterator<Item = Match>) -> Self`

### [`MatcherSet::with_matcher`]src/matcher.rs#L742

`fn(self: Self, filter: Match) -> Self`

### [`MatcherSet::add_matcher`]src/matcher.rs#L747

`fn(self: &mut Self, filter: Match)`

### [`MatcherSet::remove_matcher`]src/matcher.rs#L751

`fn(self: &mut Self, filter: &Match) -> bool`

### [`MatcherSet::clear_matchers`]src/matcher.rs#L755

`fn(self: &mut Self)`

### [`MatcherSet::is_empty`]src/matcher.rs#L759

`fn(self: &Self) -> bool`

### [`MatcherSet::iter_matchers`]src/matcher.rs#L763

`fn(self: &Self) -> Vec<&Match>`

## [`fn matches`]src/matcher.rs#L132

`fn(pattern: &str, value: &str) -> bool`

## [`trait IntoMatcherSet`]src/matcher.rs#L683

### [`IntoMatcherSet::into_matcher_set`]src/matcher.rs#L683

`fn(self: Self) -> MatcherSet`

## [`type TabCallback`]src/dispatcher.rs#L11

`type TabCallback = ...;`

## [`struct ResultSender`]src/dispatcher.rs#L304

### [`ResultSender::new`]src/dispatcher.rs#L306

`fn(sender: oneshot::Sender<Result<()>>) -> Self`

### [`ResultSender::success`]src/dispatcher.rs#L310

`fn(self: Self)`

### [`ResultSender::error`]src/dispatcher.rs#L314

`fn(self: Self, msg: impl Into<String>)`

## [`struct Config`]src/config.rs#L8

### [`Config::empty`]src/config.rs#L19

`fn() -> Self`

### [`Config::default_main`]src/config.rs#L26

`fn() -> Self`

### [`Config::from_tab`]src/config.rs#L33

`fn(tab: impl Into<Tab>) -> Self`

### [`Config::from_tabs`]src/config.rs#L41

`fn(tabs: I) -> Self`

### [`Config::main_tab`]src/config.rs#L56

Add a single tab to the config and return the modified config

`fn(self: Self, matcher_set: impl IntoMatcherSet) -> Self`

### [`Config::with_tab`]src/config.rs#L61

Add a single tab to the config and return the modified config

`fn(self: Self, name: impl Into<String>, matcher_set: impl IntoMatcherSet) -> Self`

### [`Config::with_tabs`]src/config.rs#L68

Add multiple tabs to the config and return the modified config

`fn(self: Self, tabs: impl IntoIterator<Item = (impl Into<String>, impl IntoMatcherSet)>) -> Self`

### [`Config::with_stats`]src/config.rs#L80

Enable stats tracking

`fn(self: Self, config: StatsConfig) -> Self`

### [`Config::add_tab`]src/config.rs#L86

Add a single tab to the config in-place

`fn(self: &mut Self, name: impl Into<String>, matcher_set: impl IntoMatcherSet)`

### [`Config::add_tabs`]src/config.rs#L92

Add multiple tabs to the config in-place

`fn(self: &mut Self, tabs: impl IntoIterator<Item = (impl Into<String>, impl IntoMatcherSet)>)`

## [`struct Tab`]src/config.rs#L106

### [`Tab::new`]src/config.rs#L171

`fn(name: String) -> Self`

### [`Tab::with_matcher_set`]src/config.rs#L178

`fn(self: Self, matcher_set: MatcherSet) -> Self`

### [`Tab::add_matcher`]src/config.rs#L183

`fn(self: Self, matcher: Match) -> Self`

### [`Tab::from_name_and_matchers`]src/config.rs#L191

`fn(name: S, matchers: M) -> Self`

## [`trait IntoTracerTab`]src/config.rs#L121

### [`IntoTracerTab::into_tracer_tab`]src/config.rs#L121

`fn(self: Self) -> Tab`

## [`struct TracingSubscriber`]src/tracing_subscriber.rs#L38

### [`TracingSubscriber::new`]src/tracing_subscriber.rs#L44

`fn(sender: mpsc::UnboundedSender<ArcEvent>, id_counter: Arc<AtomicU64>) -> Self`

## [`struct StatsSnapshot`]src/stats.rs#L12

COMPLETE snapshot of ALL stats data - no fucking abbreviations

## [`struct StatEntrySnapshot`]src/stats.rs#L34

Complete snapshot of a stat entry with all data

## [`struct StatsConfig`]src/stats.rs#L42

Stats configuration

## [`struct Location`]src/stats.rs#L64

Location identifier (file:line)

### [`Location::from_trace_data`]src/stats.rs#L69

`fn(data: &Event) -> Option<Self>`

## [`enum EventType`]src/stats.rs#L90

Event type for stats

## [`struct AtomicCounter`]src/stats.rs#L108

Thread-safe atomic counter

### [`AtomicCounter::new`]src/stats.rs#L112

`fn() -> Self`

### [`AtomicCounter::increment`]src/stats.rs#L118

`fn(self: &Self) -> u64`

### [`AtomicCounter::get`]src/stats.rs#L122

`fn(self: &Self) -> u64`

### [`AtomicCounter::reset`]src/stats.rs#L126

`fn(self: &Self)`

## [`struct StatEntry`]src/stats.rs#L140

Stats for a specific combination of location/module/level/event_type

### [`StatEntry::new`]src/stats.rs#L145

`fn() -> Self`

### [`StatEntry::record_event`]src/stats.rs#L157

`fn(self: &Self)`

### [`StatEntry::get_count`]src/stats.rs#L168

`fn(self: &Self) -> u64`

### [`StatEntry::get_last_seen`]src/stats.rs#L172

`fn(self: &Self) -> SystemTime`

## [`struct StatKey`]src/stats.rs#L187

Composite key for stats tracking

## [`struct StatsTracker`]src/stats.rs#L196

High-performance stats tracker

### [`StatsTracker::new`]src/stats.rs#L204

`fn(config: StatsConfig) -> Self`

### [`StatsTracker::record_event`]src/stats.rs#L228

`fn(self: &Self, event_type: EventType, trace_data: &Event)`

### [`StatsTracker::get_total_count`]src/stats.rs#L294

`fn(self: &Self, event_type: EventType, level: Level) -> u64`

### [`StatsTracker::get_total_count_by_type`]src/stats.rs#L301

`fn(self: &Self, event_type: EventType) -> u64`

### [`StatsTracker::get_snapshot`]src/stats.rs#L310

Get COMPLETE snapshot with ALL fucking data

`fn(self: &Self) -> StatsSnapshot`

### [`StatsTracker::clear`]src/stats.rs#L377

`fn(self: &Self)`

## [`struct LocationStats`]src/stats.rs#L393

Complete stats for a specific location with ALL data

### [`LocationStats::get_total_for_type`]src/stats.rs#L423

`fn(self: &Self, event_type: EventType) -> u64`

### [`LocationStats::get_total_events`]src/stats.rs#L431

`fn(self: &Self) -> u64`

## [`struct ModuleStats`]src/stats.rs#L439

Complete stats for a specific module with ALL data

### [`ModuleStats::get_total_for_type`]src/stats.rs#L469

`fn(self: &Self, event_type: EventType) -> u64`

### [`ModuleStats::get_total_events`]src/stats.rs#L477

`fn(self: &Self) -> u64`

## [`enum OutputFormat`]src/env_config.rs#L10

Output format options for trace events

## [`struct EnvConfig`]src/env_config.rs#L42

Configuration parsed from environment variables

### [`EnvConfig::from_env`]src/env_config.rs#L83

Parse configuration from environment variables

`fn() -> Result<Self>`

### [`EnvConfig::has_env_config`]src/env_config.rs#L127

Check if any environment variables are set

`fn() -> bool`

## [`struct TuiConfig`]src/env_config.rs#L61

TUI-specific debugging configuration

## [`fn parse_level`]src/env_config.rs#L257

Convert string level to tracing::Level

`fn(level: &str) -> anyhow::Result<tracing::Level>`