Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From qsu-0.4.1 To qsu-0.5.0
2024-05-20
| ||
00:11 | Merge. check-in: 343bfcf196 user: jan tags: trunk | |
00:02 | Release maintenance. Closed-Leaf check-in: 9190e0edaa user: jan tags: qsu-0.5.0, tracing-filter | |
2024-05-19
| ||
23:12 | Cleanup. check-in: 80ff88f60d user: jan tags: tracing-filter | |
20:15 | Start working on support specifying tracing filter. check-in: 322cec676c user: jan tags: tracing-filter | |
2024-05-18
| ||
22:19 | Release maintenance. check-in: f7bd4bc90c user: jan tags: qsu-0.4.1, trunk | |
22:02 | Metadata update; set to os category. check-in: f37a6b11c0 user: jan tags: trunk | |
Changes to Cargo.toml.
1 2 | [package] name = "qsu" | | | 1 2 3 4 5 6 7 8 9 10 | [package] name = "qsu" version = "0.5.0" edition = "2021" license = "0BSD" # https://crates.io/category_slugs categories = [ "os" ] keywords = [ "service", "systemd", "winsvc" ] repository = "https://repos.qrnch.tech/pub/qsu" description = "Service subsystem wrapper." |
︙ | ︙ |
Changes to src/lumberjack.rs.
1 | use std::{ | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | use std::{ env, fmt, fs, io::Write, path::{Path, PathBuf}, str::FromStr }; use time::macros::format_description; use tracing_subscriber::{fmt::time::UtcTime, EnvFilter}; #[cfg(feature = "clap")] use clap::ValueEnum; use crate::err::Error; |
︙ | ︙ | |||
25 26 27 28 29 30 31 | } /// Logging and tracing initialization. pub struct LumberJack { init: bool, log_out: LogOut, log_level: LogLevel, | | | | | | < | | < < < | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | } /// Logging and tracing initialization. pub struct LumberJack { init: bool, log_out: LogOut, log_level: LogLevel, trace_filter: Option<String>, //log_file: Option<PathBuf>, trace_file: Option<PathBuf> } impl Default for LumberJack { /// Create a default log/trace initialization. /// /// This will set the `log` log level to the value of the `LOG_LEVEL` /// environment variable, or default to `warm` (if either not set or /// invalid). /// /// The `tracing` trace level will use the environment variable /// `TRACE_FILTER` in a similar manner, but defaults to `none`. /// /// If the environment variable `TRACE_FILE` is set the value will be the /// used as the file name to write the trace logs to. fn default() -> Self { let log_level = if let Ok(level) = std::env::var("LOG_LEVEL") { if let Ok(level) = level.parse::<LogLevel>() { level } else { LogLevel::Warn } } else { LogLevel::Warn }; let trace_file = if let Ok(v) = std::env::var("TRACE_FILE") { Some(PathBuf::from(v)) } else { None }; let trace_filter = if let Ok(var) = env::var("TRACE_FILTER") { Some(var.to_string()) } else { None }; Self { init: true, log_out: Default::default(), log_level, trace_filter, //log_file: None, trace_file } } } impl LumberJack { |
︙ | ︙ | |||
110 111 112 113 114 115 116 | pub fn from_winsvc(svcname: &str) -> Result<Self, Error> { let params = crate::rt::winsvc::get_service_param(svcname)?; let loglevel = params .get_value::<String, &str>("LogLevel") .unwrap_or(String::from("warn")) .parse::<LogLevel>() .unwrap_or(LogLevel::Warn); | | > | < < | | | | | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | pub fn from_winsvc(svcname: &str) -> Result<Self, Error> { let params = crate::rt::winsvc::get_service_param(svcname)?; let loglevel = params .get_value::<String, &str>("LogLevel") .unwrap_or(String::from("warn")) .parse::<LogLevel>() .unwrap_or(LogLevel::Warn); let tracefilter = params.get_value::<String, &str>("TraceFilter"); let tracefile = params.get_value::<String, &str>("TraceFile"); let mut this = Self::new().log_level(loglevel); this.log_out = LogOut::WinEvtLog { svcname: svcname.to_string() }; let this = if let (Ok(tracefilter), Ok(tracefile)) = (tracefilter, tracefile) { this.trace_filter(tracefilter).trace_file(tracefile) } else { this }; Ok(this) } /// Set the `log` logging level. pub fn log_level(mut self, level: LogLevel) -> Self { self.log_level = level; self } /// Set the `tracing` log level. pub fn trace_filter(mut self, filter: impl ToString) -> Self { self.trace_filter = Some(filter.to_string()); self } /// Set a file to which `tracing` log entries are written (rather than to /// write to console). pub fn trace_file<P>(mut self, fname: P) -> Self where |
︙ | ︙ | |||
165 166 167 168 169 170 171 | LogOut::WinEvtLog { svcname } => { eventlog::init(&svcname, log::Level::Trace)?; log::set_max_level(self.log_level.into()); } } if let Some(fname) = self.trace_file { | | | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | LogOut::WinEvtLog { svcname } => { eventlog::init(&svcname, log::Level::Trace)?; log::set_max_level(self.log_level.into()); } } if let Some(fname) = self.trace_file { init_file_tracing(fname, self.trace_filter.as_deref()); } else { init_console_tracing(self.trace_filter.as_deref()); } Ok(()) } else { Ok(()) } } |
︙ | ︙ | |||
303 304 305 306 307 308 309 | .filter(None, lf) .init(); Ok(()) } | | < | > > > > > > > > > > > > > > | | | < < < > > > > > > > > > > > > > > > > > < > > | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | .filter(None, lf) .init(); Ok(()) } pub fn init_console_tracing(filter: Option<&str>) { /* let subscriber = FmtSubscriber::builder().with_max_level(lvl).finish(); tracing::subscriber::set_global_default(subscriber) .expect("setting default subscriber failed"); */ // When running on console, then disable tracing by default let filter = if let Some(spec) = filter { EnvFilter::new(spec) } else { EnvFilter::new("none") }; tracing_subscriber::fmt() .with_env_filter(filter) //.with_timer(timer) .init(); } /// Optionally set up tracing to a file. /// /// This function will attempt to set up tracing to a file. There are three /// conditions that must be true in order for tracing to a file to be enabled: /// - A filename must be specified (either via the `fname` argument or the /// `TRACE_FILE` environment variable). /// - A trace filter must be specified (either via the `filter` argument or the /// `TRACE_FILTER` environment variable). /// - The file name must be openable for writing. /// /// Because tracing is an optional feature and intended for development only, /// this function will enable tracing if possible, and silently ignore and /// errors. pub fn init_file_tracing<P>(fname: P, filter: Option<&str>) where P: AsRef<Path> { // // If both a trace file name and a trace level // let timer = UtcTime::new(format_description!( "[year]-[month]-[day] [hour]:[minute]:[second]" )); let f = if let Ok(f) = fs::OpenOptions::new().create(true).append(true).open(fname) { f } else { return; }; // // If TRACING_FILE is set, then default to filter out at warn level. // Disable all tracing if TRACE_FILTER is not set // let filter = if let Some(spec) = filter { EnvFilter::new(spec) } else { EnvFilter::new("warn") /* EnvFilter::builder() .with_default_directive(LevelFilter::OFF.into()) .parse("") .unwrap() */ }; tracing_subscriber::fmt() .with_env_filter(filter) .with_writer(f) .with_ansi(false) .with_timer(timer) .init(); //tracing_subscriber::registry().with(filter).init(); } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 : |
Changes to www/changelog.md.
1 2 3 4 | # Change log ## [Unreleased] | > > | > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # Change log ⚠️ indicates a breaking change. ## [Unreleased] [Details](/vdiff?from=qsu-0.5.0&to=trunk) ### Added ### Changed ### Removed --- ## [0.5.0] - 2024-05-20 [Details](/vdiff?from=qsu-0.4.1&to=qsu-0.5.0) ### Added - `TRACE_FILTER` environment variable used to configure tracing to output. - `TraceFilter` registry key on Windows used to configure tracing output. ### Changed - ⚠️ Instead of specifying a "trace level" (similar to "log level"), specify a "trace filter", allowing fine-grained control of modules to include in traces. ### Removed - `TRACE_LEVEL` environment variable no longer used. - `TraceLevel` registry key on Windows no longer used. --- ## [0.4.1] - 2024-05-19 [Details](/vdiff?from=qsu-0.4.0&to=qsu-0.4.1) ### Added |
︙ | ︙ |