Class: TermsOfUse::Logger

Inherits:
Object
  • Object
show all
Defined in:
app/services/terms_of_use/logger.rb

Constant Summary collapse

STATSD_PREFIX =
'api.terms_of_use_agreements'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(terms_of_use_agreement:) ⇒ Logger

Returns a new instance of Logger.



7
8
9
# File 'app/services/terms_of_use/logger.rb', line 7

def initialize(terms_of_use_agreement:)
  @terms_of_use_agreement = terms_of_use_agreement
end

Instance Attribute Details

#terms_of_use_agreementObject (readonly, private)

Returns the value of attribute terms_of_use_agreement.



18
19
20
# File 'app/services/terms_of_use/logger.rb', line 18

def terms_of_use_agreement
  @terms_of_use_agreement
end

Instance Method Details

#contextObject (private)



33
34
35
36
37
38
39
40
41
# File 'app/services/terms_of_use/logger.rb', line 33

def context
  @context ||= {
    terms_of_use_agreement_id: terms_of_use_agreement.id,
    user_account_uuid: .id,
    icn: .icn,
    agreement_version: terms_of_use_agreement.agreement_version,
    response: terms_of_use_agreement.response
  }
end

#increment_terms_of_use_agreement_statsdObject (private)



24
25
26
27
# File 'app/services/terms_of_use/logger.rb', line 24

def increment_terms_of_use_agreement_statsd
  StatsD.increment("#{STATSD_PREFIX}.#{prefix}",
                   tags: ["version:#{terms_of_use_agreement.agreement_version}"])
end

#log_terms_of_use_agreementObject (private)



20
21
22
# File 'app/services/terms_of_use/logger.rb', line 20

def log_terms_of_use_agreement
  Rails.logger.info("[TermsOfUseAgreement] [#{prefix.capitalize}]", context)
end

#performObject



11
12
13
14
# File 'app/services/terms_of_use/logger.rb', line 11

def perform
  log_terms_of_use_agreement
  increment_terms_of_use_agreement_statsd
end

#prefixObject (private)



29
30
31
# File 'app/services/terms_of_use/logger.rb', line 29

def prefix
  @prefix ||= terms_of_use_agreement.response
end

#user_accountObject (private)



43
44
45
# File 'app/services/terms_of_use/logger.rb', line 43

def 
  @user_account ||= terms_of_use_agreement.
end