Extract proper auditor and audit everything

This commit is contained in:
David Heinemeier Hansson
2023-02-03 20:45:32 +01:00
parent 497c57e3e5
commit 3daecf696a
9 changed files with 145 additions and 25 deletions

View File

@@ -0,0 +1,31 @@
require "active_support/core_ext/time/conversions"
require "mrsk/commands/base"
class Mrsk::Commands::Auditor < Mrsk::Commands::Base
def record(line)
append \
[ :echo, "'#{tags} #{line}'" ],
audit_log_file
end
def reveal
[ :tail, "-n", 50, audit_log_file ]
end
private
def audit_log_file
"mrsk-#{config.service}-audit.log"
end
def tags
"[#{timestamp}] [#{performer}]"
end
def performer
`whoami`.strip
end
def timestamp
Time.now.to_fs(:db)
end
end

View File

@@ -28,6 +28,10 @@ module Mrsk::Commands
combine *commands, by: "|"
end
def append(*commands)
combine *commands, by: ">>"
end
def xargs(command)
[ :xargs, command ].flatten
end