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_protocol, the_api_domain, the_api_port, the_api_key) ⇒ RemoteLogger

Returns a new instance of RemoteLogger.



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

def initialize(the_filename, the_api_protocol, the_api_domain, the_api_port, the_api_key)
  super(the_filename)
  self.api_protocol = the_api_protocol
  self.api_domain = the_api_domain
  self.api_port = the_api_port
  self.api_key = the_api_key
end

Instance Attribute Details

#api_domain ⇒ Object

Returns the value of attribute api_domain.



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

def api_domain
  @api_domain
end

#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_protocol ⇒ Object

Returns the value of attribute api_protocol.



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

def api_protocol
  @api_protocol
end

Instance Method Details

#log(s, datetime = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/remotelogger.rb', line 14

def log(s, datetime=nil)
  ltext = super(s, datetime)
  url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.4/scl/log.json"
  res = BlackStack::Netting::api_call(url, {
    'api_key' => self.api_key,
    'filename' => self.filename,
    'text' => s,
    'method' => BlackStack::BaseLogger::METHOD_LOG, 
  })
  ltext
end

#logf(s, datetime = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/remotelogger.rb', line 38

def logf(s, datetime=nil)
  ltext = super(s, datetime)
  url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.4/scl/log.json"
  res = BlackStack::Netting::api_call(url, {
    'api_key' => self.api_key,
    'filename' => self.filename,
    'text' => s,
    'method' => BlackStack::BaseLogger::METHOD_LOGF, 
  })
  ltext
end

#logs(s, datetime = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/remotelogger.rb', line 26

def logs(s, datetime=nil)
  ltext = super(s, datetime)
  url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.4/scl/log.json"
  res = BlackStack::Netting::api_call(url, {
    'api_key' => self.api_key,
    'filename' => self.filename,
    'text' => s,
    'method' => BlackStack::BaseLogger::METHOD_LOGS, 
  })
  ltext
end

#release ⇒ Object



50
51
52
53
54
55
56
# File 'lib/remotelogger.rb', line 50

def release()
  url = "#{self.api_url}:#{self.api_port.to_s}/api1.4/scl/release.json"
  res = BlackStack::Netting::api_call(url, {
    'api_key' => self.api_key,
    'filename' => self.filename, 
  })
end