Class: BlackStack::RemoteLogger

Inherits:
BaseLogger
  • Object
show all
Defined in:
lib/remotelogger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(the_filename, the_api_url, the_api_port, the_api_key) ⇒ RemoteLogger

Returns a new instance of RemoteLogger.



6
7
8
9
10
11
# File 'lib/remotelogger.rb', line 6

def initialize(the_filename, the_api_url, the_api_port, the_api_key)
  super(the_filename)
  self.api_url = the_api_url
  self.api_port = the_api_port
  self.api_key = the_api_key
end

Instance Attribute Details

#api_key ⇒ Object

Returns the value of attribute api_key.



4
5
6
# File 'lib/remotelogger.rb', line 4

def api_key
  @api_key
end

#api_port ⇒ Object

Returns the value of attribute api_port.



4
5
6
# File 'lib/remotelogger.rb', line 4

def api_port
  @api_port
end

#api_url ⇒ Object

Returns the value of attribute api_url.



4
5
6
# File 'lib/remotelogger.rb', line 4

def api_url
  @api_url
end

Instance Method Details

#log(s) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/remotelogger.rb', line 13

def log(s)
  nTries = 0
  bSuccess = false
  parsed = nil
  sError = ""
  while (nTries < 5 && bSuccess == false)
    begin
      nTries = nTries + 1
      uri = URI("#{self.api_url}:#{self.api_port}/log.json")
      res = CallPOST(uri,
        {'uid' => normalizeGuid(uid),}
      )
      parsed = JSON.parse(res.body)
      if (parsed['status']=='success')
        bSuccess = true
      else
        sError = parsed['status']
      end
    rescue Errno::ECONNREFUSED => e
      sError = "Errno::ECONNREFUSED:" + e.to_s
    rescue => e2
      sError = "Exception" + e2.to_s
    end
  end # while
  
  if (bSuccess==false)
    raise "#{sError}"
  end
end

#logf(s) ⇒ Object



46
47
# File 'lib/remotelogger.rb', line 46

def logf(s)
end

#logs(s) ⇒ Object



43
44
# File 'lib/remotelogger.rb', line 43

def logs(s)
end