Class: Ant::Server::CuteLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/ant/server/logger.rb

Instance Method Summary collapse

Instance Method Details

#access(response) ⇒ Object



14
15
16
# File 'lib/ant/server/logger.rb', line 14

def access(response)
  log_info('Requesting resource', access_data(response))
end

#access_data(response) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/ant/server/logger.rb', line 5

def access_data(response)
  {
    path: response.path,
    ip: response.ip,
    verb: response.verb,
    processing_time: (Time.now - response.params[:__init_time]).to_f * 1000
  }
end

#error(response) ⇒ Object



28
29
30
31
32
# File 'lib/ant/server/logger.rb', line 28

def error(response)
  log_warn('Error dectected on response', access_data(response).merge(
                                            error: response.exception
  ))
end

#fail(response) ⇒ Object



22
23
24
25
26
# File 'lib/ant/server/logger.rb', line 22

def fail(response)
  log_info('Fail Response',
           access_data(response)
            .merge(message: response.exception.message))
end

#fatal(response) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/ant/server/logger.rb', line 34

def fatal(response)
  log_error('Unexpected error on response',
            access_data(response).merge(
              error: response.exception,
              data: response.params
            ))
end

#success(response) ⇒ Object



18
19
20
# File 'lib/ant/server/logger.rb', line 18

def success(response)
  log_info('Success request', access_data(response))
end