Module: UU::AppLog::ApplicationLog

Extended by:
ApplicationLog
Included in:
ApplicationLog
Defined in:
uu_applog-0.8.6/lib/uu/applog/application_log.rb,
uu_applog-0.8.6/lib/uu/applog/application_log/severity.rb,
uu_applog-0.8.6/lib/uu/applog/application_log/time_conversions.rb,
uu_applog-0.8.6/lib/uu/applog/application_log/application_log_create.rb,
uu_applog-0.8.6/lib/uu/applog/application_log/application_log_add_record.rb,
uu_applog-0.8.6/lib/uu/applog/application_log/application_log_attributes.rb,
uu_applog-0.8.6/lib/uu/applog/application_log/application_log_set_attributes.rb,
uu_applog-0.8.6/lib/uu/applog/application_log/application_log_get_record_list.rb,
uu_applog-0.8.6/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. Is used for authentication optimization, where token is generated on server at first call and can be used for minimize response time in next calls

Parameters:

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

    Application log UESURI.

  • log_record (ApplicationLogAddRecord)

    DTO containing attributes of the new application log record.

  • auth_token_aware (Object) (defaults to: nil)

    is optional parameter for class aware of application log auth token with uu_application_log_auth_token accessor.

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'uu_applog-0.8.6/lib/uu/applog/application_log.rb', line 73

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.8.6/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.8.6/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.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'uu_applog-0.8.6/lib/uu/applog/application_log.rb', line 102

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.8.6/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