Module: RSMP::Logging

Included in:
Node, Proxy
Defined in:
lib/rsmp/logging.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#archiveObject (readonly)

Returns the value of attribute archive.


7
8
9
# File 'lib/rsmp/logging.rb', line 7

def archive
  @archive
end

#loggerObject (readonly)

Returns the value of attribute logger.


7
8
9
# File 'lib/rsmp/logging.rb', line 7

def logger
  @logger
end

Instance Method Details

#authorObject


14
15
# File 'lib/rsmp/logging.rb', line 14

def author
end

#initialize_logging(options) ⇒ Object


9
10
11
12
# File 'lib/rsmp/logging.rb', line 9

def initialize_logging options
  @archive = options[:archive] || RSMP::Archive.new
  @logger = options[:logger] || RSMP::Logger.new(options[:log_settings]) 
end

#log(str, options = {}) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/rsmp/logging.rb', line 17

def log str, options={}
  default = { str:str, level: :log, author: author, ip: @ip, port: @port }
  prepared = RSMP::Archive.prepare_item default.merge(options)
  @archive.add prepared
  @logger.log prepared
  prepared
end