refactor(runner): Phase 105.5 Console出力のmacro統一化
- Replace direct console.println() calls with console_println! macro - Simplify error handling in vm.rs (RC output) - Simplify success logging in selfhost.rs (PluginHost init) - Remove redundant nested if-let structures for Option handling - Macro already handles all fallback scenarios (eprintln!) This reduces code duplication and improves consistency. The macro centralizes the fallback logic, making it easier to maintain. Files modified: - src/runner/modes/vm.rs (simplified RC output) - src/runner/selfhost.rs (simplified PluginHost init message) Line reduction: ~13 lines (nested if-let structures removed)
This commit is contained in:
@ -586,17 +586,8 @@ impl NyashRunner {
|
||||
|
||||
// Quiet mode: suppress "RC:" output for JSON-only pipelines
|
||||
if !quiet_pipe {
|
||||
// Phase 98: ConsoleService if available, otherwise eprintln
|
||||
// Phase 103: Handle Option<Arc<dyn ConsoleService>>
|
||||
if let Some(host) = crate::runtime::try_get_core_plugin_host() {
|
||||
if let Some(ref console) = host.core.console {
|
||||
console.println(&format!("RC: {}", exit_code));
|
||||
} else {
|
||||
println!("RC: {}", exit_code);
|
||||
}
|
||||
} else {
|
||||
println!("RC: {}", exit_code);
|
||||
}
|
||||
// Phase 105.5: Unified console output via macro
|
||||
crate::console_println!("RC: {}", exit_code);
|
||||
}
|
||||
if std::env::var("NYASH_EMIT_MIR_TRACE")
|
||||
.ok()
|
||||
|
||||
@ -48,15 +48,11 @@ impl NyashRunner {
|
||||
let ring0 = crate::runtime::ring0::get_global_ring0();
|
||||
match crate::runtime::initialize_runtime(ring0) {
|
||||
Ok(()) => {
|
||||
// Phase 95: ConsoleService 経由でログ出力(代表パス)
|
||||
// Phase 103: Handle Option<Arc<dyn ConsoleService>>
|
||||
let host = crate::runtime::get_core_plugin_host();
|
||||
if let Some(ref console) = host.core.console {
|
||||
console.println("[selfhost] PluginHost initialized successfully");
|
||||
}
|
||||
// Phase 105.5: Unified console output via macro
|
||||
crate::console_println!("[selfhost] PluginHost initialized successfully");
|
||||
}
|
||||
Err(e) => {
|
||||
// Phase 100: ConsoleService 経由でエラー出力
|
||||
// Phase 105.5: Unified console output via macro
|
||||
crate::console_println!("[selfhost] CoreInitError: {}", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user