Sha256: d1bc128f87c3ea807ba960626027703e6d677bb97dea5c8e6d603a97a1ea1f39
Contents?: true
Size: 684 Bytes
Versions: 2
Compression:
Stored size: 684 Bytes
Contents
class Terraspace::CLI::Logs module Concern # Filters for lines that belong to the last ran process pid def readlines(path) lines = IO.readlines(path) found = lines.reverse.find do |line| pid(line) # search in reverse order for lines with interesting info end unless found puts "WARN: Could not find the pid in the logfile #{Terraspace::Util.pretty_path(path)}".color(:yellow) return [] end pid = pid(found) lines.select {|l| l.include?(" ##{pid} ") } end # [2020-09-06T21:58:25 #11313 terraspace up b1]: def pid(line) md = line.match(/:\d{2} #(\d+) /) md[1] if md end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
terraspace-0.4.1 | lib/terraspace/cli/logs/concern.rb |
terraspace-0.4.0 | lib/terraspace/cli/logs/concern.rb |