ALPHA: wire is a tool to deploy nixos systems wire.althaea.zone/
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

more work

+102 -18
+35 -3
Cargo.lock
··· 731 731 checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 732 732 733 733 [[package]] 734 + name = "hermit-abi" 735 + version = "0.5.2" 736 + source = "registry+https://github.com/rust-lang/crates.io-index" 737 + checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" 738 + 739 + [[package]] 734 740 name = "icu_collections" 735 741 version = "2.0.0" 736 742 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 869 875 ] 870 876 871 877 [[package]] 878 + name = "is-terminal" 879 + version = "0.4.16" 880 + source = "registry+https://github.com/rust-lang/crates.io-index" 881 + checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" 882 + dependencies = [ 883 + "hermit-abi", 884 + "libc", 885 + "windows-sys 0.52.0", 886 + ] 887 + 888 + [[package]] 872 889 name = "is_ci" 873 890 version = "1.2.0" 874 891 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1012 1029 "cfg-if", 1013 1030 "miette-derive", 1014 1031 "owo-colors", 1015 - "supports-color", 1032 + "supports-color 3.0.2", 1016 1033 "supports-hyperlinks", 1017 1034 "supports-unicode", 1018 1035 "terminal_size", ··· 1205 1222 1206 1223 [[package]] 1207 1224 name = "owo-colors" 1208 - version = "4.2.2" 1225 + version = "4.2.3" 1209 1226 source = "registry+https://github.com/rust-lang/crates.io-index" 1210 - checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" 1227 + checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" 1228 + dependencies = [ 1229 + "supports-color 2.1.0", 1230 + "supports-color 3.0.2", 1231 + ] 1211 1232 1212 1233 [[package]] 1213 1234 name = "parking_lot" ··· 1797 1818 version = "2.6.1" 1798 1819 source = "registry+https://github.com/rust-lang/crates.io-index" 1799 1820 checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" 1821 + 1822 + [[package]] 1823 + name = "supports-color" 1824 + version = "2.1.0" 1825 + source = "registry+https://github.com/rust-lang/crates.io-index" 1826 + checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" 1827 + dependencies = [ 1828 + "is-terminal", 1829 + "is_ci", 1830 + ] 1800 1831 1801 1832 [[package]] 1802 1833 name = "supports-color" ··· 2418 2449 "lib", 2419 2450 "miette", 2420 2451 "nix-compat", 2452 + "owo-colors", 2421 2453 "serde", 2422 2454 "serde_json", 2423 2455 "thiserror 2.0.17",
+1
wire/cli/Cargo.toml
··· 27 27 dhat = "0.3.2" 28 28 clap_complete = "4.5.59" 29 29 nix-compat = { workspace = true } 30 + owo-colors = { version = "4.2.3", features = ["supports-colors"] }
+66 -15
wire/cli/src/tracing_setup.rs
··· 9 9 10 10 use clap_verbosity_flag::{Verbosity, WarnLevel}; 11 11 use lib::STDIN_CLOBBER_LOCK; 12 - use tracing::{Level, Subscriber}; 12 + use owo_colors::{OwoColorize, Stream}; 13 + use tracing::{Subscriber}; 13 14 use tracing_log::AsTrace; 14 15 use tracing_subscriber::{ 15 - Layer, 16 - fmt::{ 17 - FormatEvent, FormatFields, 18 - format::{self, Format, Full}, 19 - }, 20 - layer::SubscriberExt, 21 - registry::LookupSpan, 22 - util::SubscriberInitExt, 16 + Layer, field::{RecordFields, VisitFmt}, fmt::{ 17 + FormatEvent, FormatFields, FormattedFields, format::{self, DefaultFields, DefaultVisitor, Format, Full} 18 + }, layer::SubscriberExt, registry::LookupSpan, util::SubscriberInitExt 23 19 }; 24 20 25 21 struct NonClobberingWriter { ··· 72 68 } 73 69 } 74 70 75 - struct WireFormat(Format<Full, ()>); 71 + struct WireEventFormat(Format<Full, ()>); 72 + struct WireFieldFormat; 73 + struct WireFieldVisitor<'a>(DefaultVisitor<'a>); 74 + 75 + impl<'a> WireFieldVisitor<'a> { 76 + fn new(writer: format::Writer<'a>, is_empty: bool) -> Self { 77 + Self(DefaultVisitor::new(writer, is_empty)) 78 + } 79 + } 80 + 81 + impl<'writer> FormatFields<'writer> for WireFieldFormat { 82 + fn format_fields<R: RecordFields>(&self, writer: format::Writer<'writer>, fields: R) -> std::fmt::Result { 83 + let mut v = WireFieldVisitor::new(writer, true); 84 + fields.record(&mut v); 85 + // v.finish() 86 + 87 + Ok(()) 88 + } 89 + } 90 + 91 + impl tracing::field::Visit for WireFieldVisitor<'_> { 92 + fn record_debug(&mut self, field: &tracing::field::Field, value: &dyn std::fmt::Debug) { 93 + match field.name() { 94 + "node" => { 95 + let _ = write!(self.0.writer(), "{:?}", value.if_supports_color(Stream::Stderr, |text| text.bold())); 96 + }, 97 + _ => return, 98 + } 99 + } 100 + } 76 101 77 - impl<S, N> FormatEvent<S, N> for WireFormat 102 + impl<S, N> FormatEvent<S, N> for WireEventFormat 78 103 where 79 104 S: Subscriber + for<'a> LookupSpan<'a>, 80 105 N: for<'a> FormatFields<'a> + 'static, ··· 82 107 fn format_event( 83 108 &self, 84 109 ctx: &tracing_subscriber::fmt::FmtContext<'_, S, N>, 85 - writer: tracing_subscriber::fmt::format::Writer<'_>, 110 + mut writer: tracing_subscriber::fmt::format::Writer<'_>, 86 111 event: &tracing::Event<'_>, 87 112 ) -> std::fmt::Result { 88 113 let metadata = event.metadata(); 89 114 90 - if !matches!(metadata.level(), &Level::INFO) { 115 + // if !matches!(metadata.level(), &tracing::Level::INFO) { 116 + // return self.0.format_event(ctx, writer, event); 117 + // } 118 + 119 + let Some(scope) = ctx.event_scope() else { 120 + return self.0.format_event(ctx, writer, event); 121 + }; 122 + 123 + let Some(parent) = scope.last() else { 124 + return self.0.format_event(ctx, writer, event); 125 + }; 126 + 127 + if parent.name() != "execute" { 91 128 return self.0.format_event(ctx, writer, event); 92 129 } 93 130 94 - self.0.format_event(ctx, writer, event)?; 131 + let Some(node_name) = parent.fields().field("node") else { 132 + return self.0.format_event(ctx, writer, event); 133 + }; 134 + 135 + let format = WireFieldFormat; 136 + 137 + let ext = parent.extensions(); 138 + let fields = &ext 139 + .get::<FormattedFields<WireFieldFormat>>() 140 + .expect("will never be `None`"); 141 + 142 + write!(writer, "{fields}")?; 143 + 144 + writeln!(writer)?; 95 145 96 146 Ok(()) 97 147 } ··· 101 151 let filter = verbosity.log_level_filter().as_trace(); 102 152 let registry = tracing_subscriber::registry(); 103 153 104 - let event_formatter = WireFormat(format::format().without_time().with_target(false)); 154 + let event_formatter = WireEventFormat(format::format().without_time().with_target(false)); 105 155 106 156 let layer = tracing_subscriber::fmt::layer() 157 + .fmt_fields(WireFieldFormat) 107 158 .event_format(event_formatter) 108 159 .with_writer(NonClobberingWriter::new) 109 160 .with_filter(filter);