par_term_config/config/config_struct/session_log_config.rs
1//! Session logging settings.
2//!
3//! Extracted from the top-level [`super::Config`] struct via `#[serde(flatten)]`.
4//! All fields serialise at the top level of the YAML config file -- existing
5//! config files remain 100% compatible.
6
7use crate::types::SessionLogFormat;
8use serde::{Deserialize, Serialize};
9
10/// Automatic session recording: format, destination and redaction.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct SessionLogConfig {
13 /// Automatically record all terminal sessions
14 /// When enabled, all terminal output is logged to files in the log directory
15 #[serde(default = "crate::defaults::bool_false")]
16 pub auto_log_sessions: bool,
17
18 /// Log format for session recording
19 /// - plain: Simple text output without escape sequences
20 /// - html: Rendered output with colors preserved
21 /// - asciicast: asciinema-compatible format for replay/sharing (default)
22 /// - asciicast_v3: like asciicast plus inline graphics as base64 events.
23 /// WARNING: embedded image pixels bypass all credential-redaction layers.
24 #[serde(default)]
25 pub session_log_format: SessionLogFormat,
26
27 /// Directory where session logs are saved
28 /// Default: ~/.local/share/par-term/logs/
29 #[serde(default = "crate::defaults::session_log_directory")]
30 pub session_log_directory: String,
31
32 /// Automatically save session log when tab/window closes
33 /// When true, ensures the session is fully written before the tab closes
34 #[serde(default = "crate::defaults::bool_true")]
35 pub archive_on_close: bool,
36
37 /// Redact input during password prompts in session logs.
38 /// When enabled, the session logger detects password prompts (sudo, ssh, etc.)
39 /// by monitoring terminal output for common prompt patterns, and replaces
40 /// any keyboard input recorded during those prompts with a redaction marker.
41 /// This prevents passwords and other credentials from being written to disk.
42 ///
43 /// WARNING: Session logs may still contain sensitive data even with this
44 /// enabled. This heuristic catches common password prompts but cannot
45 /// guarantee detection of all sensitive input scenarios.
46 #[serde(default = "crate::defaults::bool_true")]
47 pub session_log_redact_passwords: bool,
48}
49
50impl Default for SessionLogConfig {
51 fn default() -> Self {
52 Self {
53 auto_log_sessions: crate::defaults::bool_false(),
54 session_log_format: SessionLogFormat::default(),
55 session_log_directory: crate::defaults::session_log_directory(),
56 archive_on_close: crate::defaults::bool_true(),
57 session_log_redact_passwords: crate::defaults::bool_true(),
58 }
59 }
60}