Sha256: 3da20b420ddfbea0540ba0946ee46579bf058a1e2633029b328bc68bb3a3f3f1

Contents?: true

Size: 585 Bytes

Versions: 3

Compression:

Stored size: 585 Bytes

Contents

module Spanx
  module Notifier
    class AuditLog < Base
      attr_accessor :audit_file

      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

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spanx-0.3.0 lib/spanx/notifier/audit_log.rb
spanx-0.1.1 lib/spanx/notifier/audit_log.rb
spanx-0.1.0 lib/spanx/notifier/audit_log.rb