Skip to main content

run_screen_with_log_capture

Function run_screen_with_log_capture 

Source
pub fn run_screen_with_log_capture(
    command: &str,
    session_name: &str,
    user: Option<&str>,
    log_path: Option<&Path>,
) -> IsolationResult
Expand description

Run screen with log capture using -L flag + screenrc directives (for attached mode without TTY).

Uses a unified approach combining the -L flag with screenrc directives:

  • -L flag enables logging for the initial window (available on ALL screen versions)
  • logfile <path> in screenrc sets the log file path (replaces -Logfile CLI option)
  • logfile flush 0 forces immediate flushing (no 10-second delay)
  • deflog on enables logging for any additional windows

Key insight: deflog on only applies to windows created AFTER screenrc processing, but the default window is created BEFORE screenrc is processed. The -L flag is needed to enable logging for that initial window.

This replaces the previous version-dependent approach that used:

  • -L -Logfile for screen >= 4.5.1 (native logging)
  • tee fallback for screen < 4.5.1 (e.g., macOS bundled 4.0.3)