feat(app): M5 step 1, the admin backend under the management app

- datadir: the data folder layout, the location file (JARVIS_DATA_DIR wins),
  free space for the wizard.
- settings_edit: the fields the five settings screens edit; apply writes only
  non-defaults, keeps unknown keys and writes nothing unless the app's own
  check passes. A memory section reaches the worker's hello.
- secrets: config/secrets.dat, DPAPI for the Windows user; the services take
  the bot token from it before JARVIS_DISCORD_TOKEN.
- logs: the log hub behind the log screen (tabs, daily files kept 14 days,
  the recent error report, a zip under 10 MB, secrets and token-shaped text
  masked); the log macros and the worker's output feed it.

Spec: app/src/admin.spec.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 13:35:59 +09:00
parent 07c701be54
commit 390f6f0b86
18 changed files with 1457 additions and 19 deletions

View File

@@ -15,20 +15,49 @@ pub fn line(category: &str, message: &str) -> String {
format!("[{category:^10}] {message}")
}
/// Print a line and give it to the log hub when one is installed (`app/src/admin.spec.md`).
pub fn emit(level: crate::logs::Level, category: &str, message: &str) {
match level {
crate::logs::Level::Debug => eprintln!("{}", line(category, message)),
crate::logs::Level::Info => eprintln!("[{category}] {message}"),
crate::logs::Level::Warn => eprintln!("[{category}] WARN {message}"),
crate::logs::Level::Error => eprintln!("[{category}] ERROR {message}"),
}
if let Some(hub) = crate::logs::installed() {
hub.push(level, category, message);
}
}
/// Only when `JARVIS_DEBUG=1`.
#[macro_export]
macro_rules! debug_log {
($cat:expr, $($arg:tt)*) => {
if $crate::log::debug_enabled() {
eprintln!("{}", $crate::log::line($cat, &format!($($arg)*)));
$crate::log::emit($crate::logs::Level::Debug, $cat, &format!($($arg)*));
}
};
}
/// Always logged: events the log screen shows without debug logging (start, stop, joins).
#[macro_export]
macro_rules! info_log {
($cat:expr, $($arg:tt)*) => {
$crate::log::emit($crate::logs::Level::Info, $cat, &format!($($arg)*));
};
}
#[macro_export]
macro_rules! warn_log {
($cat:expr, $($arg:tt)*) => {
$crate::log::emit($crate::logs::Level::Warn, $cat, &format!($($arg)*));
};
}
/// Errors are always printed; the same rule applies: no transcript or chat text in the message.
#[macro_export]
macro_rules! error_log {
($cat:expr, $($arg:tt)*) => {
eprintln!("[{}] ERROR {}", $cat, format!($($arg)*));
$crate::log::emit($crate::logs::Level::Error, $cat, &format!($($arg)*));
};
}