Skip to content

Commit 31c9456

Browse files
RemiBardondavidB
authored andcommitted
feat: Add support for Layer::with_file
1 parent 152533d commit 31c9456

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

init-tracing-opentelemetry/src/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ impl Default for LevelConfig {
183183
#[derive(Debug, Clone)]
184184
#[allow(clippy::struct_excessive_bools)]
185185
pub struct FeatureSet {
186+
/// Include file names in output
187+
pub file_names: bool,
186188
/// Include line numbers in output
187189
pub line_numbers: bool,
188190
/// Include thread names in output
@@ -198,6 +200,7 @@ pub struct FeatureSet {
198200
impl Default for FeatureSet {
199201
fn default() -> Self {
200202
Self {
203+
file_names: true,
201204
line_numbers: cfg!(debug_assertions),
202205
thread_names: cfg!(debug_assertions),
203206
uptime_timer: true,
@@ -364,6 +367,13 @@ impl TracingConfig {
364367

365368
// === Feature Configuration ===
366369

370+
/// Enable or disable file names in output
371+
#[must_use]
372+
pub fn with_file_names(mut self, enabled: bool) -> Self {
373+
self.features.file_names = enabled;
374+
self
375+
}
376+
367377
/// Enable or disable line numbers in output
368378
#[must_use]
369379
pub fn with_line_numbers(mut self, enabled: bool) -> Self {

init-tracing-opentelemetry/src/formats.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ impl LayerBuilder for PrettyLayerBuilder {
3535
.pretty()
3636
.with_timer(tracing_subscriber::fmt::time::uptime());
3737

38+
// Configure file names
39+
if config.features.file_names {
40+
layer = layer.with_file(true);
41+
}
42+
3843
// Configure line numbers
3944
if config.features.line_numbers {
4045
layer = layer.with_line_number(true);
@@ -86,6 +91,11 @@ impl LayerBuilder for JsonLayerBuilder {
8691
.json()
8792
.with_timer(tracing_subscriber::fmt::time::uptime());
8893

94+
// Configure file names
95+
if config.features.file_names {
96+
layer = layer.with_file(true);
97+
}
98+
8999
// Configure line numbers
90100
if config.features.line_numbers {
91101
layer = layer.with_line_number(true);
@@ -136,6 +146,11 @@ impl LayerBuilder for FullLayerBuilder {
136146
let mut layer =
137147
tracing_subscriber::fmt::layer().with_timer(tracing_subscriber::fmt::time::uptime());
138148

149+
// Configure file names
150+
if config.features.file_names {
151+
layer = layer.with_file(true);
152+
}
153+
139154
// Configure line numbers
140155
if config.features.line_numbers {
141156
layer = layer.with_line_number(true);
@@ -187,6 +202,11 @@ impl LayerBuilder for CompactLayerBuilder {
187202
.compact()
188203
.with_timer(tracing_subscriber::fmt::time::uptime());
189204

205+
// Configure file names
206+
if config.features.file_names {
207+
layer = layer.with_file(true);
208+
}
209+
190210
// Configure line numbers
191211
if config.features.line_numbers {
192212
layer = layer.with_line_number(true);

0 commit comments

Comments
 (0)