Class: Spanx::Notifier::AuditLog

Inherits:
Base
  • Object
show all
Defined in:
lib/spanx/notifier/audit_log.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ AuditLog

Returns a new instance of AuditLog.

Raises:

  • (ArgumentError)


6
7
8
9
# File 'lib/spanx/notifier/audit_log.rb', line 6

def initialize(config)
  @audit_file = config[:audit_file]
  raise ArgumentError.new("config[:audit_file] is required for this notifier to work") unless @audit_file
end

Instance Attribute Details

#audit_fileObject

Returns the value of attribute audit_file.



4
5
6
# File 'lib/spanx/notifier/audit_log.rb', line 4

def audit_file
  @audit_file
end

Instance Method Details

#publish(b) ⇒ Object



11
12
13
14
15
# File 'lib/spanx/notifier/audit_log.rb', line 11

def publish(b)
  File.open(@audit_file, "a") do |file|
    file.puts "#{Time.now} -- #{sprintf("%-16s", b.identifier)} period=#{b.period_check.period_seconds}s max=#{b.period_check.max_allowed} count=#{b.sum} ttl=#{b.period_check.block_ttl}s"
  end
end