Module: UU::AppLog::ApplicationLog

Extended by:
ApplicationLog
Included in:
ApplicationLog
Defined in:
uu_applog-0.27.16/lib/uu/applog/application_log.rb,
uu_applog-0.27.16/lib/uu/applog/application_log/severity.rb,
uu_applog-0.27.16/lib/uu/applog/application_log/time_conversions.rb,
uu_applog-0.27.16/lib/uu/applog/application_log/application_log_create.rb,
uu_applog-0.27.16/lib/uu/applog/application_log/application_log_add_record.rb,
uu_applog-0.27.16/lib/uu/applog/application_log/application_log_attributes.rb,
uu_applog-0.27.16/lib/uu/applog/application_log/application_log_set_attributes.rb,
uu_applog-0.27.16/lib/uu/applog/application_log/application_log_get_record_list.rb,
uu_applog-0.27.16/lib/uu/applog/application_log/application_log_record_attributes.rb

Overview

Application log is a service designed for application debugging and monitoring.

Defined Under Namespace

Modules: TimeConversions Classes: ApplicationLogAddRecord, ApplicationLogAttributes, ApplicationLogCreate, ApplicationLogGetRecordList, ApplicationLogRecordAttributes, ApplicationLogSetAttributes, Severity

Constant Summary

PATH =

URL path of the corresponding REST service.

'uu/applog/ApplicationLog'

Instance Method Summary (collapse)

Instance Method Details

- (UU::OS::UESURI) add_record(applog_uri, log_record, auth_token_aware = nil)

Adds a new record to the specified application log.

Examples:

UU::AppLog::ApplicationLog.add_record(applog_uri,
  creation_time: Time.now,
  logger_code: "CdsGb::Cmd::CommentCreateController",
  severity: "INFO",
  message: "Comment created."
)

Parameters:

  • applog_uri (String, UU::OS::UESURI)

    UESURI of the application log to add record to.

  • log_record (ApplicationLogAddRecord)

    Attributes of the new application log record.

  • auth_token_aware (Object) (defaults to: nil)

    Optional object that is aware of application log authentication token, i.e. responding to uu_applog_auth_token method. It is used for authentication optimization - authentication token is generated on server-side during first call and then it is used to minimize response time of the next calls.

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'uu_applog-0.27.16/lib/uu/applog/application_log.rb', line 86

def add_record(applog_uri, log_record, auth_token_aware=nil)
  svc = UU::OS::REST::RemoteClient.new(ApplicationLog)
  payload = ApplicationLog::ApplicationLogAddRecord.new(log_record).to_json

  if auth_token_aware.respond_to?:uu_applog_auth_token
    svc.add_header('uu-applog-token', auth_token_aware.uu_applog_auth_token) unless auth_token_aware.nil?
  end
  # QoS is not checked for this operation (records shall be created
  # regardless of QoS limits so that the related issues can be
  # troubleshooted)
  raw_res = svc.raw_post('addRecord', applog_uri, payload)
  res = svc.send(:process_result, raw_res) #TODO change send to normal method call if become public

  # set token to the auth token aware class only if there is some
  if auth_token_aware.respond_to?:uu_applog_auth_token
    token = raw_res[2][:uu_applog_token]
    auth_token_aware.uu_applog_auth_token=token unless auth_token_aware.nil? || token.nil? || token.empty?
  end

  return UU::OS::UESURI.new(res)
end

- (UU:OS::UESURI) create(uuapp_uri, applog_attributes = nil)

Creates a new application log in the specified uuApplication.

Parameters:

  • uuapp_uri (String, UU::OS::UESURI)

    uuApplication UESURI.

  • applog_attributes (ApplicationLogCreate) (defaults to: nil)

    DTO containing attributes of the new application log.

Returns:

  • (UU:OS::UESURI)

    UESURI of the new application log.



29
30
31
32
33
34
35
36
37
# File 'uu_applog-0.27.16/lib/uu/applog/application_log.rb', line 29

def create(uuapp_uri, applog_attributes = nil)
  svc = UU::OS::REST::RemoteClient.new(ApplicationLog)
  payload = ApplicationLog::ApplicationLogCreate.new(applog_attributes).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('create', uuapp_uri, payload)
    return UU::OS::UESURI.new(res)
  end
end

- (ApplicationLogAttributes) get_attributes(applog_uri)

Get application log configuration attributes.

Parameters:

  • applog_uri (String, UU::OS::UESURI)

    UESURI of the application log

Returns:



43
44
45
46
47
48
49
# File 'uu_applog-0.27.16/lib/uu/applog/application_log.rb', line 43

def get_attributes(applog_uri)
  svc = UU::OS::REST::RemoteClient.new(ApplicationLog)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getAttributes', applog_uri)
    return ApplicationLog::ApplicationLogAttributes.new(res)
  end
end

- (Array) get_record_list(applog_uri, criteria = nil)

Returns a list of records from the specified application log. The list can optionally be limited and/or ordered (see the criteria parameter).

Parameters:

Returns:

  • (Array)

    Array of application log records according to the specified criteria.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'uu_applog-0.27.16/lib/uu/applog/application_log.rb', line 115

def get_record_list(applog_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(ApplicationLog)
  dto = ApplicationLog::ApplicationLogGetRecordList.new(criteria)
  svc.add_parameter('timeFrom', dto.time_from)
  svc.add_parameter('timeTo', dto.time_to)
  svc.add_parameter('offset', dto.offset)
  svc.add_parameter('limit', dto.limit)

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getRecordList', applog_uri)
    data = JSON.parse(res, :symbolize_names => true)
    result = data.map { |value| ApplicationLog::ApplicationLogRecordAttributes.new(value)}
    return result
  end
end

- (UU::OS::UESURI) set_attributes(applog_uri, applog_set_attributes = nil)

Set configuration attributes of the application log.

Parameters:

Returns:



56
57
58
59
60
61
62
63
# File 'uu_applog-0.27.16/lib/uu/applog/application_log.rb', line 56

def set_attributes(applog_uri, applog_set_attributes = nil)
  svc = UU::OS::REST::RemoteClient.new(ApplicationLog)
  payload = ApplicationLog::ApplicationLogSetAttributes.new(applog_set_attributes)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('setAttributes', applog_uri, payload.to_json)
    return UU::OS::UESURI.new(res)
  end
end