Class: ReceiveNginxLogs

Inherits:
Object
  • Object
show all
Defined in:
lib/hot_catch/receive_nginx_logs.rb

Overview

Принцип получения логов (сделано так, чтобы не потерять логи за секунду между интервалами выборок):

1. 

Constant Summary collapse

SinceDatetimeGetLogsFormat =
"%Y-%m-%d %H:%M:%S %z"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReceiveNginxLogs

Returns a new instance of ReceiveNginxLogs.



18
19
20
21
22
23
24
25
26
# File 'lib/hot_catch/receive_nginx_logs.rb', line 18

def initialize
  @last_get_logs_time_filename = 'tmp/hot_catch_from_time.txt'
  @input_filename = 'log/nginx.access.log'
  @format_datetime_logs = "%d/%b/%Y:%H:%M:%S %z"
  @regexp_datetime_logs = /\d{2}\/\w+\/\d{4}:\d{2}:\d{2}:\d{2}\s\+\d{4}/
  @delta_get_logs = 1.seconds
  @logs = []
  @since_datetime_get_logs = nil
end

Instance Attribute Details

#format_datetime_logsObject

Returns the value of attribute format_datetime_logs.



13
14
15
# File 'lib/hot_catch/receive_nginx_logs.rb', line 13

def format_datetime_logs
  @format_datetime_logs
end

#input_filenameObject

Returns the value of attribute input_filename.



13
14
15
# File 'lib/hot_catch/receive_nginx_logs.rb', line 13

def input_filename
  @input_filename
end

#last_get_logs_time_filenameObject

Returns the value of attribute last_get_logs_time_filename.



13
14
15
# File 'lib/hot_catch/receive_nginx_logs.rb', line 13

def last_get_logs_time_filename
  @last_get_logs_time_filename
end

#regexp_datetime_logsObject

Returns the value of attribute regexp_datetime_logs.



13
14
15
# File 'lib/hot_catch/receive_nginx_logs.rb', line 13

def regexp_datetime_logs
  @regexp_datetime_logs
end

Instance Method Details

#get_last_logsObject



28
29
30
31
32
# File 'lib/hot_catch/receive_nginx_logs.rb', line 28

def get_last_logs
  read_logs
  cut_logs
  @logs.join("")
end