mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 21:30:41 +00:00
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:
parent
bf5d60c77c
commit
7889dffdea
6 changed files with 45 additions and 21 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -1403,7 +1403,7 @@ version = "0.0.1-placeholder"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg6dev"
|
name = "pkg6dev"
|
||||||
version = "0.1.1"
|
version = "0.5.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap 4.5.41",
|
"clap 4.5.41",
|
||||||
|
|
@ -1417,7 +1417,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg6repo"
|
name = "pkg6repo"
|
||||||
version = "0.0.1-placeholder"
|
version = "0.5.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 4.5.41",
|
"clap 4.5.41",
|
||||||
"flate2",
|
"flate2",
|
||||||
|
|
|
||||||
10
Cargo.toml
10
Cargo.toml
|
|
@ -11,5 +11,13 @@ members = [
|
||||||
"crates/*",
|
"crates/*",
|
||||||
"xtask",
|
"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>"]
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pkg6dev"
|
name = "pkg6dev"
|
||||||
version = "0.1.1"
|
version.workspace = true
|
||||||
authors = ["Till Wegmueller <till.wegmueller@openflowlabs.com>"]
|
authors.workspace = true
|
||||||
edition = "2018"
|
edition.workspace = true
|
||||||
license-file = "LICENSE"
|
license-file.workspace = true
|
||||||
description = "Helper tool for IPS package development"
|
description = "Helper tool for IPS package development"
|
||||||
repository = "https://github.com/OpenFlowLabs/ips"
|
repository.workspace = true
|
||||||
readme = "README.md"
|
readme.workspace = true
|
||||||
keywords = ["packaging", "illumos"]
|
keywords.workspace = true
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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 = "*"}
|
userland = {path = "../userland", version = "*"}
|
||||||
clap = {version = "4", features = [ "derive" ] }
|
clap = {version = "4", features = [ "derive" ] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
miette = { version = "7", features = ["fancy"] }
|
miette = { version = "7", features = ["fancy"] }
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
|
@ -126,6 +126,14 @@ pub enum Pkg6DevError {
|
||||||
path: PathBuf,
|
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)
|
// Generic custom error (for backward compatibility)
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
#[diagnostic(
|
#[diagnostic(
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ use std::fs::{read_dir, OpenOptions};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use tracing::{debug, info, warn};
|
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::repology::find_newest_version;
|
||||||
use userland::{Component, Makefile};
|
use userland::{Component, Makefile};
|
||||||
|
|
||||||
|
|
@ -57,9 +58,16 @@ enum Commands {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
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()
|
fmt::Subscriber::builder()
|
||||||
.with_max_level(tracing::Level::WARN)
|
.with_max_level(tracing::Level::DEBUG)
|
||||||
|
.with_env_filter(env_filter)
|
||||||
.without_time()
|
.without_time()
|
||||||
.with_target(false)
|
.with_target(false)
|
||||||
.with_ansi(false)
|
.with_ansi(false)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pkg6repo"
|
name = "pkg6repo"
|
||||||
version = "0.0.1-placeholder"
|
version.workspace = true
|
||||||
authors = ["Till Wegmueller <till.wegmueller@openflowlabs.com>"]
|
authors.workspace = true
|
||||||
edition = "2018"
|
edition.workspace = true
|
||||||
license-file = "LICENSE"
|
license-file.workspace = true
|
||||||
description = "The repository management utility for IPS written in rust"
|
description = "The repository management utility for IPS written in rust"
|
||||||
repository = "https://github.com/OpenFlowLabs/pkg6dev"
|
repository.workspace = true
|
||||||
readme = "README.md"
|
readme.workspace = true
|
||||||
keywords = ["packaging", "illumos"]
|
keywords.workspace = true
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue