Class: Bracken::Logfile

Inherits:
Object
  • Object
show all
Defined in:
lib/bracken/logfile.rb,
lib/bracken/logfile/filter.rb,
lib/bracken/logfile/stream.rb

Defined Under Namespace

Modules: Stream Classes: Filter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, number_of_lines) ⇒ Logfile

Returns a new instance of Logfile.



11
12
13
14
15
# File 'lib/bracken/logfile.rb', line 11

def initialize(path, number_of_lines)
  @filters         = []
  @number_of_lines = number_of_lines
  @path            = path
end

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.



7
8
9
# File 'lib/bracken/logfile.rb', line 7

def filters
  @filters
end

#number_of_linesObject (readonly)

Returns the value of attribute number_of_lines.



8
9
10
# File 'lib/bracken/logfile.rb', line 8

def number_of_lines
  @number_of_lines
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/bracken/logfile.rb', line 9

def path
  @path
end

Instance Method Details

#streamObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bracken/logfile.rb', line 17

def stream
  @stream ||= begin
    pid, _, out, _ = Open4.popen4("tail -n #{number_of_lines} -F #{path}")

    out.extend(Stream)
    out.logfile = self
    out.pid     = pid

    out
  end
end