to be private not public API

This commit is contained in:
uu59 2014-07-03 14:14:51 +09:00
parent e240dd5600
commit 2f50f07c8a
2 changed files with 29 additions and 25 deletions

View File

@ -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

View File

@ -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