Add audit broadcasts

This commit is contained in:
David Heinemeier Hansson
2023-02-18 11:36:30 +01:00
parent 5c93642f2a
commit fb9357b5ba
6 changed files with 80 additions and 5 deletions

View File

@@ -1,12 +1,22 @@
require "active_support/core_ext/time/conversions"
class Mrsk::Commands::Auditor < Mrsk::Commands::Base
# Runs remotely
def record(line)
append \
[ :echo, tagged_line(line) ],
audit_log_file
end
# Runs locally
def broadcast(line)
if broadcast_cmd = config.audit_broadcast_cmd
pipe \
[ :echo, tagged_line(line) ],
broadcast_cmd
end
end
def reveal
[ :tail, "-n", 50, audit_log_file ]
end
@@ -21,14 +31,14 @@ class Mrsk::Commands::Auditor < Mrsk::Commands::Base
end
def tags
"[#{timestamp}] [#{performer}]"
"[#{recorded_at}] [#{performer}]"
end
def performer
`whoami`.strip
@performer ||= `whoami`.strip
end
def timestamp
def recorded_at
Time.now.to_fs(:db)
end
end