Class: BitcoinNode::P2p::LoggingProbe

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin_node/p2p/probe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(progname) ⇒ LoggingProbe

Returns a new instance of LoggingProbe.



24
25
26
27
# File 'lib/bitcoin_node/p2p/probe.rb', line 24

def initialize(progname)
  @logger = ::Logger.new(STDOUT)
  @logger.progname = progname.upcase
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



22
23
24
# File 'lib/bitcoin_node/p2p/probe.rb', line 22

def logger
  @logger
end

Instance Method Details

#<<(hash) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bitcoin_node/p2p/probe.rb', line 29

def <<(hash)
  hash.each do |key, value|
    case key
    when :sending then logger.info("Sending #{value}")
    when :receiving then logger.info("Receiving #{value}")
    when :connected then logger.info("Connected to #{value}")
    when :connection then logger.info("Connection received from #{value}")
    when :closed then logger.info("Closed connection to #{value}")
    else logger.unknown('Cannot log that!!')
    end
  end
end