Update workspace structure, unify metadata, enhance logging, and expand error handling

- Centralize package metadata in workspace for consistency.
- Upgrade `pkg6dev` and `pkg6repo` to version `0.5.1`, aligning with new workspace configuration.
- Introduce `EnvFilter` for dynamic logging configuration, defaulting to debug level.
- Add `LoggingEnvError` variant to `Pkg6DevError` with structured diagnostics for improved error handling.
This commit is contained in:
Till Wegmueller 2025-07-27 11:08:39 +02:00
parent bf5d60c77c
commit 7889dffdea
No known key found for this signature in database
6 changed files with 45 additions and 21 deletions

4
Cargo.lock generated
View file

@ -1403,7 +1403,7 @@ version = "0.0.1-placeholder"
[[package]]
name = "pkg6dev"
version = "0.1.1"
version = "0.5.1"
dependencies = [
"anyhow",
"clap 4.5.41",
@ -1417,7 +1417,7 @@ dependencies = [
[[package]]
name = "pkg6repo"
version = "0.0.1-placeholder"
version = "0.5.1"
dependencies = [
"clap 4.5.41",
"flate2",

View file

@ -11,5 +11,13 @@ members = [
"crates/*",
"xtask",
]
resolver = "2"
resolver = "2"
[workspace.package]
version = "0.5.1"
edition = "2024"
license-file = "LICENSE"
repository = "https://github.com/OpenFlowLabs/ips"
readme = "README.md"
keywords = ["packaging", "illumos"]
authors = ["Till Wegmueller <toasterson@gmail.com>"]

View file

@ -1,13 +1,13 @@
[package]
name = "pkg6dev"
version = "0.1.1"
authors = ["Till Wegmueller <till.wegmueller@openflowlabs.com>"]
edition = "2018"
license-file = "LICENSE"
version.workspace = true
authors.workspace = true
edition.workspace = true
license-file.workspace = true
description = "Helper tool for IPS package development"
repository = "https://github.com/OpenFlowLabs/ips"
readme = "README.md"
keywords = ["packaging", "illumos"]
repository.workspace = true
readme.workspace = true
keywords.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -16,7 +16,7 @@ libips = {path = "../libips", version = "0.1"}
userland = {path = "../userland", version = "*"}
clap = {version = "4", features = [ "derive" ] }
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
miette = { version = "7", features = ["fancy"] }
thiserror = "2"
anyhow = "1.0"

View file

@ -126,6 +126,14 @@ pub enum Pkg6DevError {
path: PathBuf,
},
// Logging environment error
#[error("logging environment setup error: {0}")]
#[diagnostic(
code(ips::pkg6dev::logging_env_error),
help("Check your logging environment configuration and try again")
)]
LoggingEnvError(String),
// Generic custom error (for backward compatibility)
#[error("{0}")]
#[diagnostic(

View file

@ -10,7 +10,8 @@ use std::fs::{read_dir, OpenOptions};
use std::io::Write;
use std::path::{Path, PathBuf};
use tracing::{debug, info, warn};
use tracing_subscriber::fmt;
use tracing_subscriber::{fmt, EnvFilter};
use tracing_subscriber::filter::LevelFilter;
use userland::repology::find_newest_version;
use userland::{Component, Makefile};
@ -57,9 +58,16 @@ enum Commands {
}
fn main() -> Result<()> {
// Initialize the tracing subscriber with default log level as warning and no decorations
// Initialize the tracing subscriber with the default log level as debug and no decorations
// Parse the environment filter first, handling any errors with our custom error type
let env_filter = EnvFilter::builder()
.with_default_directive(LevelFilter::WARN.into())
.from_env()
.map_err(|e| Pkg6DevError::LoggingEnvError(format!("Failed to parse environment filter: {}", e)))?;
fmt::Subscriber::builder()
.with_max_level(tracing::Level::WARN)
.with_max_level(tracing::Level::DEBUG)
.with_env_filter(env_filter)
.without_time()
.with_target(false)
.with_ansi(false)

View file

@ -1,13 +1,13 @@
[package]
name = "pkg6repo"
version = "0.0.1-placeholder"
authors = ["Till Wegmueller <till.wegmueller@openflowlabs.com>"]
edition = "2018"
license-file = "LICENSE"
version.workspace = true
authors.workspace = true
edition.workspace = true
license-file.workspace = true
description = "The repository management utility for IPS written in rust"
repository = "https://github.com/OpenFlowLabs/pkg6dev"
readme = "README.md"
keywords = ["packaging", "illumos"]
repository.workspace = true
readme.workspace = true
keywords.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html