diff --git a/Cargo.lock b/Cargo.lock index 69eeed1..2709c2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,6 +44,12 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "arrayvec" version = "0.7.2" @@ -704,6 +710,7 @@ dependencies = [ "sdk", "serde", "serde_sjson", + "strip-ansi-escapes", "time", "tokio", "tokio-stream", @@ -1425,7 +1432,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db8c31eaef73f18e0d938785e01ab471ec73e3f90c3389e84335ade689ba953b" dependencies = [ - "arrayvec", + "arrayvec 0.7.2", "serde", ] @@ -2401,6 +2408,15 @@ dependencies = [ "regex", ] +[[package]] +name = "strip-ansi-escapes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "011cbb39cf7c1f62871aea3cc46e5817b0937b49e9447370c93cacbe93a766d8" +dependencies = [ + "vte", +] + [[package]] name = "strsim" version = "0.10.0" @@ -2692,6 +2708,12 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "ucd-trie" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + [[package]] name = "unic-bidi" version = "0.9.0" @@ -2818,6 +2840,27 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vte" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983" +dependencies = [ + "arrayvec 0.5.2", + "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte_generate_state_changes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/crates/dtmm/Cargo.toml b/crates/dtmm/Cargo.toml index a54177b..261a994 100644 --- a/crates/dtmm/Cargo.toml +++ b/crates/dtmm/Cargo.toml @@ -25,3 +25,4 @@ zip = "0.6.4" tokio-stream = { version = "0.1.12", features = ["fs"] } path-slash = "0.2.1" time = { version = "0.3.20", features = ["serde", "serde-well-known", "local-offset"] } +strip-ansi-escapes = "0.1.1" diff --git a/crates/dtmm/src/util/log.rs b/crates/dtmm/src/util/log.rs index e6a019e..1b379dc 100644 --- a/crates/dtmm/src/util/log.rs +++ b/crates/dtmm/src/util/log.rs @@ -20,7 +20,8 @@ impl ChannelWriter { impl std::io::Write for ChannelWriter { fn write(&mut self, buf: &[u8]) -> std::io::Result { let tx = self.tx.clone(); - let string = String::from_utf8_lossy(buf).to_string(); + let stripped = strip_ansi_escapes::strip(buf)?; + let string = String::from_utf8_lossy(&stripped).to_string(); // The `send` errors when the receiving end has closed. // But there's not much we can do at that point, so we just ignore it.