Module: Mutx::Support::Logs

Defined in:
lib/mutx/support/logs.rb

Class Method Summary collapse

Class Method Details

.allObject



10
11
12
13
14
15
16
17
18
# File 'lib/mutx/support/logs.rb', line 10

def self.all
  logs = Hash.new
  Dir.glob(path + '*.log') do |log_file|
    name = log_file.split("/").last.gsub('.log','')
    text = File.read(log_file)
    logs[name] = text
  end
  logs
end

.pathObject



6
7
8
# File 'lib/mutx/support/logs.rb', line 6

def self.path
  "#{Dir.pwd}/mutx/"
end

.read_log_file_content_for(log = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mutx/support/logs.rb', line 20

def self.read_log_file_content_for log=nil
    path = "#{Dir.pwd}/mutx/logs/#{log}.log"
    if File.exist?("#{path}")
      FileUtils.cp(path, "#{path}~")
      all_content = IO.read("#{path}~")[-4000..-1]
      content = all_content.gsub("\n","<br>")
      File.delete("#{path}~")
    else
      content = ""
    end
    content
end