tracing_subscriber_init/config.rs
1// Copyright (c) 2023 tracing-subscriber-init developers
2//
3// Licensed under the Apache License, Version 2.0
4// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT
5// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. All files in the project carrying such notice may not be copied,
7// modified, or distributed except according to those terms.
8
9use tracing_subscriber::fmt::format::FmtSpan;
10
11/// Implement this trait to supply tracing configuration that can be used to build a [`Layer`](tracing_subscriber::Layer)
12/// with functions such as [`full_filtered`](crate::full_filtered).
13pub trait Config {
14 /// Get the quiet count (these are normally pulled from the command line arguments)
15 fn quiet(&self) -> u8;
16 /// Get the verbose count (these are normally pulled from the command line arguments)
17 fn verbose(&self) -> u8;
18 /// Sets whether or not the formatter emits ANSI terminal escape codes for colors and other text formatting.
19 /// This defaults to true
20 fn with_ansi(&self) -> bool {
21 true
22 }
23 /// Sets whether or not the formatter will include the current span in formatted events.
24 /// This defaults to false
25 #[cfg(feature = "json")]
26 #[cfg_attr(docsrs, doc(cfg(feature = "json")))]
27 fn with_current_span(&self) -> bool {
28 false
29 }
30 /// Sets whether or not an event’s source code file path is displayed.
31 /// This defaults to false
32 fn with_file(&self) -> bool {
33 false
34 }
35 /// Sets whether or not an event’s source code line number is displayed.
36 /// This defaults to false
37 fn with_line_number(&self) -> bool {
38 false
39 }
40 /// Sets whether or not an event’s level is displayed.
41 /// This defaults to true
42 fn with_level(&self) -> bool {
43 true
44 }
45 /// Configures how synthesized events are emitted at points in the span lifecycle.
46 /// This defaults to [`None`](std::option::Option::None).
47 /// See [`with_span_event`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.with_span_events)
48 fn with_span_events(&self) -> Option<FmtSpan> {
49 None
50 }
51 /// Sets whether or not the formatter will include a list (from root to leaf) of all currently entered spans in formatted events.
52 /// This defaults to false
53 #[cfg(feature = "json")]
54 #[cfg_attr(docsrs, doc(cfg(feature = "json")))]
55 fn with_span_list(&self) -> bool {
56 false
57 }
58 /// Sets whether or not an event’s target is displayed.
59 /// This defaults to false
60 fn with_target(&self) -> bool {
61 false
62 }
63 /// Sets whether or not the thread ID of the current thread is displayed when formatting events.
64 /// This defaults to false
65 fn with_thread_ids(&self) -> bool {
66 false
67 }
68 /// Sets whether or not the name of the current thread is displayed when formatting events.
69 /// This defaults to false
70 fn with_thread_names(&self) -> bool {
71 false
72 }
73}