From 44c3f10befb3f728898017b9ba9a6bc4161af799 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 5 Sep 2022 11:56:56 +0200 Subject: Fix to improve debug logging --- src/tokenizer.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/tokenizer.rs') diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 0ab8784..8843e47 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -13,7 +13,14 @@ use crate::parser::ParseState; use crate::resolve::{call as call_resolve, Name as ResolveName}; use crate::state::{call, State}; use crate::util::{constant::TAB_SIZE, edit_map::EditMap}; -use alloc::{boxed::Box, string::String, vec, vec::Vec}; +use alloc::{ + boxed::Box, + format, + string::{String, ToString}, + vec, + vec::Vec, +}; +use core::str; /// Containers. /// @@ -714,7 +721,14 @@ fn push_impl( None }; - log::debug!("feed: `{:?}` to {:?}", byte, name); + let visible = byte.map(|d| { + if (b' '..=b'~').contains(&d) { + str::from_utf8(&[d]).unwrap().to_string() + } else { + format!("0x{:x}", d) + } + }); + log::debug!("feed: `{:?}` to {:?}", visible, name); tokenizer.expect(byte); state = call(tokenizer, name); }; -- cgit