Skip to content

Commit cc95319

Browse files
davidbarskyhawkw
authored andcommitted
core: add support for recording 128-bit integers (#2166)
## Motivation I've received a request at work to record 128-bit integers and realized that we should probably support recording them. ## Solution Added two methods to the `Visit` trait, `record_i128` and `record_u128`. However, I didn't add the size conversions present for 64-bit integers, as 128-bit integers are, at this time, more specialized.
1 parent a6cb13e commit cc95319

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tracing-core/src/field.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
//! will contain any fields attached to each event.
1717
//!
1818
//! `tracing` represents values as either one of a set of Rust primitives
19-
//! (`i64`, `u64`, `f64`, `bool`, and `&str`) or using a `fmt::Display` or
20-
//! `fmt::Debug` implementation. `Subscriber`s are provided these primitive
21-
//! value types as `dyn Value` trait objects.
19+
//! (`i64`, `u64`, `f64`, `i128`, `u128`, `bool`, and `&str`) or using a
20+
//! `fmt::Display` or `fmt::Debug` implementation. `Subscriber`s are provided
21+
//! these primitive value types as `dyn Value` trait objects.
2222
//!
2323
//! These trait objects can be formatted using `fmt::Debug`, but may also be
2424
//! recorded as typed data by calling the [`Value::record`] method on these
@@ -278,6 +278,16 @@ pub trait Visit {
278278
self.record_debug(field, &value)
279279
}
280280

281+
/// Visit a signed 128-bit integer value.
282+
fn record_i128(&mut self, field: &Field, value: i128) {
283+
self.record_debug(field, &value)
284+
}
285+
286+
/// Visit an unsigned 128-bit integer value.
287+
fn record_u128(&mut self, field: &Field, value: u128) {
288+
self.record_debug(field, &value)
289+
}
290+
281291
/// Visit a boolean value.
282292
fn record_bool(&mut self, field: &Field, value: bool) {
283293
self.record_debug(field, &value)
@@ -490,6 +500,8 @@ impl_values! {
490500
record_u64(usize, u32, u16, u8 as u64),
491501
record_i64(i64),
492502
record_i64(isize, i32, i16, i8 as i64),
503+
record_u128(u128),
504+
record_i128(i128),
493505
record_bool(bool),
494506
record_f64(f64, f32 as f64)
495507
}

0 commit comments

Comments
 (0)