Clean up 404 KCL references (99.75% complete): - Rename kcl_* variables to schema_*/nickel_* (kcl_path→schema_path, etc.) - Update functions: parse_kcl_file→parse_nickel_file - Update env vars: KCL_MOD_PATH→NICKEL_IMPORT_PATH - Fix cli/providers-install: add has_nickel and nickel_version variables - Correct import syntax: .nickel.→.ncl. - Update 57 files across core, CLI, config, and utilities Configure pre-commit hooks: - Activate: nushell-check, nickel-typecheck, markdownlint - Comment out: Rust hooks (fmt, clippy, test), check-yaml Testing: - Module discovery: 9 modules (6 providers, 1 taskserv, 2 clusters) ✅ - Syntax validation: 15 core files ✅ - Pre-commit hooks: all passing ✅
96 lines
2.8 KiB
Plaintext
96 lines
2.8 KiB
Plaintext
# Enhanced logging system for provisioning tool
|
||
|
||
use ../config/accessor.nu *
|
||
|
||
# Check if debug mode is enabled
|
||
export def is-debug-enabled []: nothing -> bool {
|
||
(config-get "debug.enabled" false)
|
||
}
|
||
|
||
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)"
|
||
}
|