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 #[serde(default)]
23 pub session_log_format: SessionLogFormat,
24
25 /// Directory where session logs are saved
26 /// Default: ~/.local/share/par-term/logs/
27 #[serde(default = "crate::defaults::session_log_directory")]
28 pub session_log_directory: String,
29
30 /// Automatically save session log when tab/window closes
31 /// When true, ensures the session is fully written before the tab closes
32 #[serde(default = "crate::defaults::bool_true")]
33 pub archive_on_close: bool,
34
35 /// Redact input during password prompts in session logs.
36 /// When enabled, the session logger detects password prompts (sudo, ssh, etc.)
37 /// by monitoring terminal output for common prompt patterns, and replaces
38 /// any keyboard input recorded during those prompts with a redaction marker.
39 /// This prevents passwords and other credentials from being written to disk.
40 ///
41 /// WARNING: Session logs may still contain sensitive data even with this
42 /// enabled. This heuristic catches common password prompts but cannot
43 /// guarantee detection of all sensitive input scenarios.
44 #[serde(default = "crate::defaults::bool_true")]
45 pub session_log_redact_passwords: bool,
46}
47
48impl Default for SessionLogConfig {
49 fn default() -> Self {
50 Self {
51 auto_log_sessions: crate::defaults::bool_false(),
52 session_log_format: SessionLogFormat::default(),
53 session_log_directory: crate::defaults::session_log_directory(),
54 archive_on_close: crate::defaults::bool_true(),
55 session_log_redact_passwords: crate::defaults::bool_true(),
56 }
57 }
58}