Class: EmmyHttp::Client::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/emmy_http/client/monitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/emmy_http/client/monitor.rb', line 5

def logger
  @logger
end

Instance Method Details

#bind(op) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/emmy_http/client/monitor.rb', line 7

def bind(op)
  @operation = op

  # operation events

  op.on :init do
    logger.debug "connected"
  end

  op.on :head do
    logger.debug "headers received"
  end

  op.on :success do |response, operation, conn|
    logger.info("request success with status #{response.status}")
  end

  op.on :error do |message|
    logger.error(message)
  end

  # client events

  op.adapter.client.on :change do |state, client|
    logger.debug "change state to #{state}"
  end

end