mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 10:56:11 +02:00
to be private not public API
This commit is contained in:
parent
e240dd5600
commit
2f50f07c8a
@ -57,13 +57,16 @@ class Fluentd
|
||||
extra_options[:config_file] || self.class.default_options[:config_file]
|
||||
end
|
||||
|
||||
|
||||
# define these methods on each Agent class
|
||||
|
||||
%w(start stop restart).each do |method|
|
||||
define_method(method) do
|
||||
raise NotImplementedError
|
||||
end
|
||||
end
|
||||
|
||||
%w(running? log config config_write config_append logged_errors log_tail configuration).each do |method|
|
||||
%w(running? log config config_write config_append log_tail configuration).each do |method|
|
||||
define_method(method) do
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
class Fluentd
|
||||
class Agent
|
||||
module LocalCommon
|
||||
def pid
|
||||
return unless File.exists?(pid_file)
|
||||
File.read(pid_file).to_i rescue nil
|
||||
end
|
||||
|
||||
def running?
|
||||
begin
|
||||
pid && Process.kill(0, pid)
|
||||
@ -35,6 +30,31 @@ class Fluentd
|
||||
f.write content
|
||||
end
|
||||
end
|
||||
def log_tail(limit = nil)
|
||||
limit = limit.to_i rescue 0
|
||||
limit = limit.zero? ? Settings.default_log_tail_count : limit
|
||||
io = File.open(log_file)
|
||||
buf = []
|
||||
reader = ::FileReverseReader.new(io)
|
||||
reader.each_line do |line|
|
||||
buf << line
|
||||
break if buf.length >= limit
|
||||
end
|
||||
buf
|
||||
end
|
||||
|
||||
def configuration
|
||||
if File.exists? config_file
|
||||
::Fluentd::Agent::Configuration.new(config_file)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pid
|
||||
return unless File.exists?(pid_file)
|
||||
File.read(pid_file).to_i rescue nil
|
||||
end
|
||||
|
||||
def logged_errors(&block)
|
||||
return [] unless File.exist?(log_file)
|
||||
@ -72,25 +92,6 @@ class Fluentd
|
||||
ensure
|
||||
io && io.close
|
||||
end
|
||||
|
||||
def log_tail(limit = nil)
|
||||
limit = limit.to_i rescue 0
|
||||
limit = limit.zero? ? Settings.default_log_tail_count : limit
|
||||
io = File.open(log_file)
|
||||
buf = []
|
||||
reader = ::FileReverseReader.new(io)
|
||||
reader.each_line do |line|
|
||||
buf << line
|
||||
break if buf.length >= limit
|
||||
end
|
||||
buf
|
||||
end
|
||||
|
||||
def configuration
|
||||
if File.exists? config_file
|
||||
::Fluentd::Agent::Configuration.new(config_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user