@@ -7,7 +7,7 @@ use core::{cmp, fmt, str::FromStr};
7
7
8
8
use flipperzero_sys as sys;
9
9
10
- /// Describes the level of verbosity of a span or event .
10
+ /// Describes the level of verbosity of a log message .
11
11
///
12
12
/// # Comparing Levels
13
13
///
@@ -19,7 +19,7 @@ use flipperzero_sys as sys;
19
19
///
20
20
/// For example:
21
21
/// ```
22
- /// use tracing_core ::Level;
22
+ /// use flipperzero::furi::log ::Level;
23
23
///
24
24
/// assert!(Level::TRACE > Level::DEBUG);
25
25
/// assert!(Level::ERROR < Level::WARN);
@@ -30,25 +30,25 @@ use flipperzero_sys as sys;
30
30
/// # Filtering
31
31
///
32
32
/// `Level`s are typically used to implement filtering that determines which
33
- /// spans and events are enabled. Depending on the use case, more or less
33
+ /// log messages are enabled. Depending on the use case, more or less
34
34
/// verbose diagnostics may be desired. For example, when running in
35
- /// development, [`DEBUG`]-level traces may be enabled by default. When running in
36
- /// production, only [`INFO`]-level and lower traces might be enabled. Libraries
35
+ /// development, [`DEBUG`]-level logs may be enabled by default. When running in
36
+ /// production, only [`INFO`]-level and lower logs might be enabled. Libraries
37
37
/// may include very verbose diagnostics at the [`DEBUG`] and/or [`TRACE`] levels.
38
- /// Applications using those libraries typically chose to ignore those traces . However, when
38
+ /// Applications using those libraries typically chose to ignore those logs . However, when
39
39
/// debugging an issue involving said libraries, it may be useful to temporarily
40
- /// enable the more verbose traces .
40
+ /// enable the more verbose logs .
41
41
///
42
- /// The [`LevelFilter`] type is provided to enable filtering traces by
42
+ /// The [`LevelFilter`] type is provided to enable filtering logs by
43
43
/// verbosity. `Level`s can be compared against [`LevelFilter`]s, and
44
44
/// [`LevelFilter`] has a variant for each `Level`, which compares analogously
45
45
/// to that level. In addition, [`LevelFilter`] adds a [`LevelFilter::OFF`]
46
46
/// variant, which is considered "less verbose" than every other `Level`. This is
47
- /// intended to allow filters to completely disable tracing in a particular context.
47
+ /// intended to allow filters to completely disable logging in a particular context.
48
48
///
49
49
/// For example:
50
50
/// ```
51
- /// use tracing_core ::{Level, LevelFilter};
51
+ /// use flipperzero::furi::log ::{Level, LevelFilter};
52
52
///
53
53
/// assert!(LevelFilter::OFF < Level::TRACE);
54
54
/// assert!(LevelFilter::TRACE > Level::DEBUG);
@@ -59,83 +59,15 @@ use flipperzero_sys as sys;
59
59
///
60
60
/// ## Examples
61
61
///
62
- /// Below is a simple example of how a [collector] could implement filtering through
63
- /// a [`LevelFilter`]. When a span or event is recorded, the [`Collect::enabled`] method
64
- /// compares the span or event's `Level` against the configured [`LevelFilter`].
65
- /// The optional [`Collect::max_level_hint`] method can also be implemented to allow spans
66
- /// and events above a maximum verbosity level to be skipped more efficiently,
67
- /// often improving performance in short-lived programs.
68
- ///
69
- /// ```
70
- /// use tracing_core::{span, Event, Level, LevelFilter, Collect, Metadata};
71
- /// # use tracing_core::span::{Id, Record, Current};
72
- ///
73
- /// #[derive(Debug)]
74
- /// pub struct MyCollector {
75
- /// /// The most verbose level that this collector will enable.
76
- /// max_level: LevelFilter,
77
- ///
78
- /// // ...
79
- /// }
80
- ///
81
- /// impl MyCollector {
82
- /// /// Returns a new `MyCollector` which will record spans and events up to
83
- /// /// `max_level`.
84
- /// pub fn with_max_level(max_level: LevelFilter) -> Self {
85
- /// Self {
86
- /// max_level,
87
- /// // ...
88
- /// }
89
- /// }
90
- /// }
91
- /// impl Collect for MyCollector {
92
- /// fn enabled(&self, meta: &Metadata<'_>) -> bool {
93
- /// // A span or event is enabled if it is at or below the configured
94
- /// // maximum level.
95
- /// meta.level() <= &self.max_level
96
- /// }
97
- ///
98
- /// // This optional method returns the most verbose level that this
99
- /// // collector will enable. Although implementing this method is not
100
- /// // *required*, it permits additional optimizations when it is provided,
101
- /// // allowing spans and events above the max level to be skipped
102
- /// // more efficiently.
103
- /// fn max_level_hint(&self) -> Option<LevelFilter> {
104
- /// Some(self.max_level)
105
- /// }
106
- ///
107
- /// // Implement the rest of the collector...
108
- /// fn new_span(&self, span: &span::Attributes<'_>) -> span::Id {
109
- /// // ...
110
- /// # drop(span); Id::from_u64(1)
111
- /// }
112
-
113
- /// fn event(&self, event: &Event<'_>) {
114
- /// // ...
115
- /// # drop(event);
116
- /// }
117
- ///
118
- /// // ...
119
- /// # fn enter(&self, _: &Id) {}
120
- /// # fn exit(&self, _: &Id) {}
121
- /// # fn record(&self, _: &Id, _: &Record<'_>) {}
122
- /// # fn record_follows_from(&self, _: &Id, _: &Id) {}
123
- /// # fn current_span(&self) -> Current { Current::unknown() }
124
- /// }
125
- /// ```
126
- ///
127
- /// It is worth noting that the `tracing-subscriber` crate provides [additional
128
- /// APIs][envfilter] for performing more sophisticated filtering, such as
129
- /// enabling different levels based on which module or crate a span or event is
130
- /// recorded in.
62
+ /// `Level` should generally be used with the [`log`] macro via its associated
63
+ /// constants. You can also use the helper macros like [`warn`] directly without
64
+ /// needing to specify a `Level`.
131
65
///
132
66
/// [`DEBUG`]: Level::DEBUG
133
67
/// [`INFO`]: Level::INFO
134
68
/// [`TRACE`]: Level::TRACE
135
- /// [`Collect::enabled`]: crate::collect::Collect::enabled
136
- /// [`Collect::max_level_hint`]: crate::collect::Collect::max_level_hint
137
- /// [collector]: crate::collect::Collect
138
- /// [envfilter]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html
69
+ /// [`log`]: crate::log
70
+ /// [`warn`]: crate::warn
139
71
#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
140
72
pub struct Level ( LevelInner ) ;
141
73
@@ -147,7 +79,7 @@ pub struct Level(LevelInner);
147
79
/// details.
148
80
///
149
81
/// Note that this is essentially identical to the `Level` type, but with the
150
- /// addition of an [`OFF`] level that completely disables all trace
82
+ /// addition of an [`OFF`] level that completely disables all logging
151
83
/// instrumentation.
152
84
///
153
85
/// See the documentation for the [`Level`] type to see how `Level`s
@@ -308,7 +240,7 @@ impl LevelFilter {
308
240
/// Designates very low priority, often extremely verbose, information.
309
241
pub const TRACE : LevelFilter = LevelFilter :: from_level ( Level :: TRACE ) ;
310
242
311
- /// Returns a `LevelFilter` that enables spans and events with verbosity up
243
+ /// Returns a `LevelFilter` that enables log messages with verbosity up
312
244
/// to and including `level`.
313
245
pub const fn from_level ( level : Level ) -> Self {
314
246
Self ( match level. 0 {
@@ -336,22 +268,21 @@ impl LevelFilter {
336
268
}
337
269
}
338
270
339
- /// Returns a `LevelFilter` that matches the most verbose [`Level`] that any
340
- /// currently active [collector] will enable.
271
+ /// Returns a `LevelFilter` that matches the most verbose [`Level`] that the
272
+ /// Furi Logging system will enable.
341
273
///
342
- /// User code should treat this as a *hint*. If a given span or event has a
274
+ /// User code should treat this as a *hint*. If a given log message has a
343
275
/// level *higher* than the returned `LevelFilter`, it will not be enabled.
344
- /// However, if the level is less than or equal to this value, the span or
345
- /// event is *not* guaranteed to be enabled; the collector will still
346
- /// filter each callsite individually .
276
+ /// However, if the level is less than or equal to this value, the log
277
+ /// message is *not* guaranteed to be enabled; the Furi Logging system may
278
+ /// perform additional filtering .
347
279
///
348
- /// Therefore, comparing a given span or event 's level to the returned
280
+ /// Therefore, comparing a given log message 's level to the returned
349
281
/// `LevelFilter` **can** be used for determining if something is
350
282
/// *disabled*, but **should not** be used for determining if something is
351
283
/// *enabled*.
352
284
///
353
285
/// [`Level`]: super::Level
354
- /// [collector]: super::Collect
355
286
#[ inline( always) ]
356
287
pub fn current ( ) -> Self {
357
288
match unsafe { sys:: furi_log_get_level ( ) } {
0 commit comments