Class: Fluent::TraOutput

Inherits:
BufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_gri.rb

Instance Method Summary collapse

Instance Method Details

#format(tag, time, record) ⇒ Object



82
83
84
# File 'lib/fluent/plugin/out_gri.rb', line 82

def format tag, time, record
  [tag, time, record].to_msgpack
end

#startObject



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fluent/plugin/out_gri.rb', line 69

def start
  super
  if @log_level
    ::Log.init '/tmp/out_tra.log', :log_level=>@log_level
  end
  GRI::Config.init @config_path
  root_dir = GRI::Config['root-dir'] ||= GRI::Config::ROOT_PATH
  plugin_dirs = GRI::Config.getvar('plugin-dir') || [root_dir + '/plugin']
  GRI::Plugin.load_plugins plugin_dirs
  @tra_dir ||= GRI::Config['tra-dir'] || root_dir + '/tra'
  @interval ||= (GRI::Config['interval'] || 300).to_i
end

#write(chunk) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/fluent/plugin/out_gri.rb', line 86

def write chunk
  records = []
  chunk.msgpack_each {|tag, time, record|
    records.push record
  }
  writer = GRI::Writer.create 'ldb', :tra_dir=>@tra_dir, :interval=>@interval
  writer.write records
  writer.finalize
end