Fix error when log file is not created yet

This commit is contained in:
uu59 2014-07-03 15:00:16 +09:00
parent 5f8e28a841
commit e73915c76e

View File

@ -11,6 +11,7 @@ class Fluentd
end end
def log def log
return "" unless File.exists?(log_file)
File.read(log_file) # TODO: large log file File.read(log_file) # TODO: large log file
end end
@ -32,6 +33,8 @@ class Fluentd
end end
def log_tail(limit = nil) def log_tail(limit = nil)
return [] unless File.exists?(log_file)
limit = limit.to_i rescue 0 limit = limit.to_i rescue 0
limit = limit.zero? ? Settings.default_log_tail_count : limit limit = limit.zero? ? Settings.default_log_tail_count : limit
io = File.open(log_file) io = File.open(log_file)