pub fn init_logging(args: &Args) -> Result<Option<WorkerGuard>>Expand description
Initialize logging based on configuration arguments.
This function sets up tracing subscribers with:
- Environment-based log level filtering (falls back to
args.log_level) - Stderr output in text format (stdout is reserved for MCP protocol)
- Optional file logging with rotation support
§Returns
Ok(Some(WorkerGuard))- File logging enabled, guard must be kept aliveOk(None)- No file logging configuredErr(SshMcpError)- Configuration or IO error
§Note
The WorkerGuard must be stored for the entire program lifetime when file
logging is enabled, or the background worker will be dropped and logs may be lost.