Class: Kodo::Memory::Audit
- Inherits:
-
Object
- Object
- Kodo::Memory::Audit
- Defined in:
- lib/kodo/memory/audit.rb
Instance Method Summary collapse
-
#initialize ⇒ Audit
constructor
A new instance of Audit.
-
#log(event:, channel: nil, detail: nil) ⇒ Object
Log an event to the audit trail.
-
#today ⇒ Object
Read today's audit log.
Constructor Details
#initialize ⇒ Audit
Returns a new instance of Audit.
10 11 12 13 |
# File 'lib/kodo/memory/audit.rb', line 10 def initialize @audit_dir = File.join(Kodo.home_dir, "memory", "audit") FileUtils.mkdir_p(@audit_dir) end |
Instance Method Details
#log(event:, channel: nil, detail: nil) ⇒ Object
Log an event to the audit trail
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kodo/memory/audit.rb', line 16 def log(event:, channel: nil, detail: nil) entry = { "timestamp" => Time.now.iso8601, "event" => event, "channel" => channel, "detail" => detail }.compact append_to_daily_log(entry) Kodo.logger.debug("Audit: #{event} #{detail&.slice(0, 80)}") end |
#today ⇒ Object
Read today's audit log
29 30 31 |
# File 'lib/kodo/memory/audit.rb', line 29 def today read_log(Date.today) end |