Class FileAuditLogger
java.lang.Object
cloud.opencode.base.feature.audit.FileAuditLogger
- All Implemented Interfaces:
AuditLogger
File Audit Logger
文件审计日志记录器
Audit logger that writes events to a file.
将事件写入文件的审计日志记录器。
Features | 主要功能:
- File-based logging - 文件日志记录
- Append mode - 追加模式
- Simple text format - 简单文本格式
Usage Examples | 使用示例:
AuditLogger logger = new FileAuditLogger(Path.of("audit.log"));
logger.log(new FeatureAuditEvent(...));
// Output:
// [2024-01-15T10:30:00Z] ENABLE: feature=dark-mode, operator=admin, false -> true
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Partial (validates inputs) - 空值安全: 部分(验证输入)
- Since:
- JDK 25, opencode-base-feature V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the log file path 获取日志文件路径voidlog(FeatureAuditEvent event) Log audit event to file 将审计事件记录到文件
-
Constructor Details
-
FileAuditLogger
Create file audit logger. 创建文件审计日志记录器。V1.0.4 sec round-5 P2: normalises
logFileto absolute form so any configuration-driven path with../segments is resolved at construction time rather than left to the JVM's CWD-dependent semantics. Caller is still responsible for vetting the source oflogFile— this is hardening, not full input validation. V1.0.4 sec round-5 P2:将logFile归一化为绝对路径,让配置驱动的含../路径在构造期就解析,而非交给 JVM 依赖 CWD 的语义。logFile来源仍由调用方负责 把关 —— 这是加固,非完整输入校验。- Parameters:
logFile- the log file path | 日志文件路径
-
-
Method Details
-
log
Log audit event to file 将审计事件记录到文件- Specified by:
login interfaceAuditLogger- Parameters:
event- the audit event | 审计事件
-
getLogFile
-