- DAG architecture: `dag show/validate/export` (nulib/main_provisioning/dag.nu),
config loader (lib_provisioning/config/loader/dag.nu), taskserv dag-executor.
Backed by schemas/lib/dag/*.ncl; orchestrator emits NATS events via
WorkspaceComposition::into_workflow. See ADR-020, ADR-021.
- Unified Component Architecture: components/mod.nu, main_provisioning/
{components,workflow,extensions,ontoref-queries}.nu. Full workflow engine with
topological sort and NATS subject emission. Blocks A-H complete (libre-daoshi).
- Commands-registry: nulib/commands-registry.ncl (Nickel source, 314 lines) +
JSON cache at ~/.cache/provisioning/commands-registry.json rebuilt on source
change. cli/provisioning fast-path alias expansion avoids cold Nu startup.
ADDING_COMMANDS.md documents new-command workflow.
- Platform service manager: service-manager.nu (+573), startup.nu (+611),
service-check.nu (+255); autostart/bootstrap/health/target refactored.
- Nushell 0.112.2 migration: removed all try/catch and bash redirections;
external commands prefixed with ^; type signatures enforced. Driven by
scripts/refactor-try-catch{,-simplified}.nu.
- TTY stack: removed shlib/*-tty.sh; replaced by cli/tty-dispatch.sh,
tty-filter.sh, tty-commands.conf.
- New domain modules: images/ (golden image lifecycle), workspace/{state,sync}.nu,
main_provisioning/{bootstrap,cluster-deploy,fip,state}.nu, commands/{state,
build,integrations/auth,utilities/alias}.nu, platform.nu expanded (+874).
- Config loader overhaul: loader/core.nu slimmed (-759), cache/core.nu
refactored (-454), removed legacy loaders/file_loader.nu (-330).
- Thirteen new provisioning-<domain>.nu top-level modules for bash dispatcher.
- Tests: test_workspace_state.nu (+351); updates to test_oci_registry,
test_services.
- README + CHANGELOG updated.
120 lines
3.7 KiB
Text
120 lines
3.7 KiB
Text
# Enhanced logging system for provisioning tool
|
||
|
||
use ../config/accessor.nu *
|
||
|
||
# Check if debug mode is enabled
|
||
export def is-debug-enabled [] {
|
||
let raw = ($env.PROVISIONING_DEBUG? | default false)
|
||
let env_debug = if ($raw | describe) == "string" { $raw == "true" or $raw == "1" } else { $raw | into bool }
|
||
let config_debug = (config-get "debug.enabled" false)
|
||
$env_debug or $config_debug
|
||
}
|
||
|
||
# Check if debug-check mode is enabled (local task/service simulation)
|
||
export def is-debug-check-enabled [] {
|
||
$env.PROVISIONING_DEBUG_CHECK? | default false | into bool
|
||
}
|
||
|
||
# Check if metadata mode is enabled (for detailed error spans/metadata)
|
||
export def is-metadata-enabled [] {
|
||
let env_metadata = ($env.PROVISIONING_METADATA? | default false)
|
||
let config_metadata = (config-get "debug.metadata" false)
|
||
$env_metadata or $config_metadata
|
||
}
|
||
|
||
# Enable debug mode
|
||
export def set-debug-enabled [value: bool] {
|
||
$env.PROVISIONING_DEBUG = $value
|
||
}
|
||
|
||
# Enable metadata mode
|
||
export def set-metadata-enabled [value: bool] {
|
||
$env.PROVISIONING_METADATA = $value
|
||
}
|
||
|
||
export def log-info [
|
||
message: string
|
||
context?: string
|
||
] {
|
||
let timestamp = (date now | format date '%Y-%m-%d %H:%M:%S')
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
print $"ℹ️ ($timestamp)($context_str) ($message)"
|
||
}
|
||
|
||
export def log-success [
|
||
message: string
|
||
context?: string
|
||
] {
|
||
let timestamp = (date now | format date '%Y-%m-%d %H:%M:%S')
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
print $"✅ ($timestamp)($context_str) ($message)"
|
||
}
|
||
|
||
export def log-warning [
|
||
message: string
|
||
context?: string
|
||
] {
|
||
let timestamp = (date now | format date '%Y-%m-%d %H:%M:%S')
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
print $"⚠️ ($timestamp)($context_str) ($message)"
|
||
}
|
||
|
||
export def log-error [
|
||
message: string
|
||
context?: string
|
||
details?: string
|
||
] {
|
||
let timestamp = (date now | format date '%Y-%m-%d %H:%M:%S')
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
let details_str = if ($details | is-not-empty) { $"\n Details: ($details)" } else { "" }
|
||
print $"🛑 ($timestamp)($context_str) ($message)($details_str)"
|
||
}
|
||
|
||
export def log-debug [
|
||
message: string
|
||
context?: string
|
||
] {
|
||
if (is-debug-enabled) {
|
||
let timestamp = (date now | format date '%Y-%m-%d %H:%M:%S')
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
print $"🐛 ($timestamp)($context_str) ($message)"
|
||
}
|
||
}
|
||
|
||
export def log-step [
|
||
step: string
|
||
total_steps: int
|
||
current_step: int
|
||
context?: string
|
||
] {
|
||
let progress = $"($current_step)/($total_steps)"
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
print $"🔄 ($progress)($context_str) ($step)"
|
||
}
|
||
|
||
export def log-progress [
|
||
message: string
|
||
percent: int
|
||
context?: string
|
||
] {
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
print $"📊 ($context_str) ($message) ($percent)%"
|
||
}
|
||
|
||
export def log-section [
|
||
title: string
|
||
context?: string
|
||
] {
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
print $""
|
||
print $"📋 ($context_str) ($title)"
|
||
print $"─────────────────────────────────────────────────────────────"
|
||
}
|
||
|
||
export def log-subsection [
|
||
title: string
|
||
context?: string
|
||
] {
|
||
let context_str = if ($context | is-not-empty) { $" [($context)]" } else { "" }
|
||
print $" 📌 ($context_str) ($title)"
|
||
}
|