Class: Ant::Server::Logger

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

Overview

Implements monitoring. This will add logs. Currently it only support CuteLogger format, but it will be deprecated in order to support a new log (actually kind of the same format).

Instance Method Summary collapse

Instance Method Details

#access(response) ⇒ Object



21
22
23
# File 'lib/ant/server/logger.rb', line 21

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

#access_data(response) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/ant/server/logger.rb', line 11

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



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

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

#fail(response) ⇒ Object



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

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

#fatal(response) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/ant/server/logger.rb', line 41

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

#success(response) ⇒ Object



25
26
27
# File 'lib/ant/server/logger.rb', line 25

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