Extract proper auditor and audit everything
This commit is contained in:
31
lib/mrsk/commands/auditor.rb
Normal file
31
lib/mrsk/commands/auditor.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user