Class: Spanx::Notifier::AuditLog
- Defined in:
- lib/spanx/notifier/audit_log.rb
Instance Attribute Summary collapse
-
#audit_file ⇒ Object
Returns the value of attribute audit_file.
Instance Method Summary collapse
-
#initialize(config) ⇒ AuditLog
constructor
A new instance of AuditLog.
- #publish(b) ⇒ Object
Constructor Details
#initialize(config) ⇒ AuditLog
Returns a new instance of AuditLog.
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_file ⇒ Object
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 |