Skip to content

Commit 201d21a

Browse files
authored
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 68bc91f commit 201d21a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tracing-core/src/field.rs

+15-3
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. Collectors 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. Collectors 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
@@ -194,6 +194,16 @@ pub trait Visit {
194194
self.record_debug(field, &value)
195195
}
196196

197+
/// Visit a signed 128-bit integer value.
198+
fn record_i128(&mut self, field: &Field, value: i128) {
199+
self.record_debug(field, &value)
200+
}
201+
202+
/// Visit an unsigned 128-bit integer value.
203+
fn record_u128(&mut self, field: &Field, value: u128) {
204+
self.record_debug(field, &value)
205+
}
206+
197207
/// Visit a boolean value.
198208
fn record_bool(&mut self, field: &Field, value: bool) {
199209
self.record_debug(field, &value)
@@ -393,6 +403,8 @@ impl_values! {
393403
record_u64(usize, u32, u16, u8 as u64),
394404
record_i64(i64),
395405
record_i64(isize, i32, i16, i8 as i64),
406+
record_u128(u128),
407+
record_i128(i128),
396408
record_bool(bool),
397409
record_f64(f64, f32 as f64)
398410
}

0 commit comments

Comments
 (0)