Class: F4w::Logging::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/f4w/logging/entry.rb

Constant Summary collapse

VERSION =
1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, type_of_call, user_id, app_data, error_data) ⇒ Entry

Returns a new instance of Entry.



17
18
19
20
21
22
23
24
25
# File 'lib/f4w/logging/entry.rb', line 17

def initialize(uri, type_of_call, user_id, app_data, error_data)
  @service_uri = uri
  @type_of_call = type_of_call
  @app_data_log_record = app_data
  @error_log_record = error_data
  @user_id = user_id

  @invocation_zoned_date_time = DateTime.now.iso8601(3)
end

Instance Attribute Details

#app_data_log_recordObject

Returns the value of attribute app_data_log_record.



10
11
12
# File 'lib/f4w/logging/entry.rb', line 10

def app_data_log_record
  @app_data_log_record
end

#error_log_recordObject

Returns the value of attribute error_log_record.



11
12
13
# File 'lib/f4w/logging/entry.rb', line 11

def error_log_record
  @error_log_record
end

#invocation_zoned_date_timeObject

Returns the value of attribute invocation_zoned_date_time.



12
13
14
# File 'lib/f4w/logging/entry.rb', line 12

def invocation_zoned_date_time
  @invocation_zoned_date_time
end

#service_uriObject

Returns the value of attribute service_uri.



13
14
15
# File 'lib/f4w/logging/entry.rb', line 13

def service_uri
  @service_uri
end

#type_of_callObject

Returns the value of attribute type_of_call.



14
15
16
# File 'lib/f4w/logging/entry.rb', line 14

def type_of_call
  @type_of_call
end

#user_idObject

Returns the value of attribute user_id.



15
16
17
# File 'lib/f4w/logging/entry.rb', line 15

def user_id
  @user_id
end

Class Method Details

.error(uri, user_id, error_context, error_message, data = nil) ⇒ Object



49
50
51
# File 'lib/f4w/logging/entry.rb', line 49

def self.error(uri, user_id, error_context, error_message, data = nil)
  log_request(uri, '-1', user_id, data, error_context, error_message)
end

.request_end(uri, user_id, data = nil) ⇒ Object



45
46
47
# File 'lib/f4w/logging/entry.rb', line 45

def self.request_end(uri, user_id, data = nil)
  log_request(uri, '2', user_id, data)
end

.request_start(uri, user_id, data = nil) ⇒ Object



41
42
43
# File 'lib/f4w/logging/entry.rb', line 41

def self.request_start(uri, user_id, data = nil)
  log_request(uri, '1', user_id, data)
end

Instance Method Details

#as_json(options = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/f4w/logging/entry.rb', line 27

def as_json(options = nil)
  json = {
    'invocationZonedDateTime' => @invocation_zoned_date_time,
    'serviceURI' => @service_uri,
    'tyepeOfCall' => @type_of_call
  }

  json['appDataLogRecord'] = @app_data_log_record.as_json(options) unless @app_data_log_record.nil?
  json['errorLogRecord'] = @error_log_record.as_json(options) unless @error_log_record.nil?
  json['userID'] = @user_id unless @user_id.nil?

  json
end

#to_sObject



53
54
55
# File 'lib/f4w/logging/entry.rb', line 53

def to_s
  "ver=#{VERSION} log=#{to_json}"
end