用户投诉原话:「我们的启动日志放在哪?…他找半天没找到崩溃日志」「只有一个安装日志」。 启动器运行日志(.ULL/logs/launcher.log) - presenter 构造 HostEnv 时就登记日志目录:启动早期缓冲的 200 行([probe]/[font]/[theme]) 当场刷盘,不再是「只有开过一局游戏才有日志」。 - app/** 里所有 eprintln! 诊断改走 app::diag::diag!(stderr + 文件双写,行首 [tag] 即 scope), 含 boot/boot::fallback/state/update 各线。 - boot 那一拍补一行后端事实(request/effective/fallback)。 - 滚动上限(1 MiB → launcher.1.log,只留一份)写进 README 与 docs/logs-location.md。 会话日志搬家:data/agent/sessions → logs - LauncherLayout: sessions_root()/game_logs() 新增,agent_sessions() 降级为只读兼容。 - host/logs 与 cli/commands/sessions 两个根合并(同 id 新根优先),event_path 回落旧家。 - 不搬不删;日志目录写一份 session-log-location.json 记录(moved=0, policy=read-only-compat)。 入口与文案 - 设置页「通用」新增「日志文件夹」行:路径 + 打开目录 + 复制路径(i18n 中英)。 - 日志页页头的「打开目录」不再是占位:走 M187 的 open_dir,失败文本带路径并送进剪贴板。 - README.md / README.zh-CN.md 新增「日志在哪」章节(含 crash-reports 只在游戏走到那一步才有), docs/logs-location.md 给出上限、双写判据、迁移策略与没验的部分。 守门(每条都有变异证明,见报告) - 旧家会话仍列得出/打不开 ⇒ 只读新根变红;新会话写 logs/game ⇒ 只读旧根、写回旧家都变红。 - launcher.log 滚动 ⇒ 干掉 rename 变红。 - 打开日志文件夹指向真实目录 ⇒ 换成 cache/ 或去掉 create_dir_all 都变红。 - 日志根随三模式变化 ⇒ 把 HostEnv::logs_dir 写死成便携落点变红。
63 lines
2.0 KiB
Rust
63 lines
2.0 KiB
Rust
//! 端口装配:把 `unlucky-core` 的实现塞进 agent 的五个端口。
|
||
//!
|
||
//! 为什么这一层在 CLI 而不在 agent:agent 只知道 trait(`#!` 依赖倒置),
|
||
//! `crates/app` 是 GUI 的装配处,而 `ull agent serve` 是**headless 的另一个装配入口**。
|
||
//! 放这里让 CLI 自洽,也让 GUI 后续复用同一批适配器(把本目录上移到 app 是一次纯搬家)。
|
||
//!
|
||
//! 每个文件一个端口,与 `crates/agent/src/port*.rs` 一一对应,读起来不用跳来跳去。
|
||
|
||
pub mod accounts;
|
||
pub mod diagnose;
|
||
pub mod events;
|
||
pub mod game;
|
||
pub mod session;
|
||
pub mod setting;
|
||
|
||
use std::sync::Arc;
|
||
|
||
use unlucky_agent::port::Ports;
|
||
use unlucky_core::platform::data_dir::DataMode;
|
||
use unlucky_core::platform::paths::Platform;
|
||
|
||
use crate::context::Ctx;
|
||
|
||
pub use accounts::CoreAccounts;
|
||
pub use diagnose::CoreDiagnose;
|
||
pub use game::CoreGame;
|
||
pub use session::CoreSessions;
|
||
pub use setting::CoreSetting;
|
||
|
||
/// 按一次 CLI 上下文装配五个端口。
|
||
#[must_use]
|
||
pub fn build(ctx: &Ctx) -> Ports {
|
||
Ports {
|
||
// 数据根键(`core.*`)落便携目录那份,与 `Ctx::resolve` 同源——CLI `config set`
|
||
// 与 AI `set_config` 共用 `Ctx` 给出的两个落点(finding …-agent-settingport-core-ai)。
|
||
setting: Arc::new(CoreSetting::split(
|
||
ctx.launcher_config(),
|
||
ctx.portable_launcher_config(),
|
||
)),
|
||
sessions: Arc::new(
|
||
CoreSessions::new(ctx.sessions_root()).with_legacy(ctx.legacy_sessions_root()),
|
||
),
|
||
diagnose: Arc::new(
|
||
CoreDiagnose::new(ctx.sessions_root()).with_legacy(ctx.legacy_sessions_root()),
|
||
),
|
||
game: Arc::new(CoreGame::new(
|
||
ctx.layout(),
|
||
ctx.game(),
|
||
data_mode(ctx),
|
||
platform(ctx),
|
||
)),
|
||
accounts: Arc::new(CoreAccounts::new(ctx.auth_data())),
|
||
}
|
||
}
|
||
|
||
pub(crate) fn data_mode(ctx: &Ctx) -> DataMode {
|
||
ctx.data.mode
|
||
}
|
||
|
||
pub(crate) fn platform(ctx: &Ctx) -> Platform {
|
||
ctx.platform
|
||
}
|