Class: OllamaAgent::Resilience::AuditLogger
- Inherits:
-
Object
- Object
- OllamaAgent::Resilience::AuditLogger
- Defined in:
- lib/ollama_agent/resilience/audit_logger.rb
Overview
Subscribes to Streaming::Hooks and writes structured NDJSON audit logs. Activated by OLLAMA_AGENT_AUDIT=1 or audit: true in Runner.build.
Constant Summary collapse
- DEFAULT_MAX_RESULT_BYTES =
4_096
Instance Method Summary collapse
- #attach ⇒ Object
-
#initialize(log_dir:, hooks:, max_result_bytes: nil) ⇒ AuditLogger
constructor
A new instance of AuditLogger.
Constructor Details
#initialize(log_dir:, hooks:, max_result_bytes: nil) ⇒ AuditLogger
Returns a new instance of AuditLogger.
13 14 15 16 17 |
# File 'lib/ollama_agent/resilience/audit_logger.rb', line 13 def initialize(log_dir:, hooks:, max_result_bytes: nil) @log_dir = log_dir @hooks = hooks @max_result_bytes = max_result_bytes || env_max_result_bytes end |
Instance Method Details
#attach ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/ollama_agent/resilience/audit_logger.rb', line 19 def attach @hooks.on(:on_tool_call) { |payload| write_entry(tool_call_entry(payload)) } @hooks.on(:on_tool_result) { |payload| write_entry(tool_result_entry(payload)) } @hooks.on(:on_complete) { |payload| write_entry(complete_entry(payload)) } @hooks.on(:on_error) { |payload| write_entry(error_entry(payload)) } @hooks.on(:on_retry) { |payload| write_entry(retry_entry(payload)) } end |