Class: Fluent::PluginClass

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

Instance Method Summary collapse

Constructor Details

#initializePluginClass

This class is refactored using Fluent::Registry at v0.14



23
24
25
26
27
28
# File 'lib/fluent/plugin.rb', line 23

def initialize
  @input = {}
  @output = {}
  @filter = {}
  @buffer = {}
end

Instance Method Details

#load_plugin(type, name) ⇒ Object



95
96
97
# File 'lib/fluent/plugin.rb', line 95

def load_plugin(type, name)
  try_load_plugin(name, type)
end

#load_plugin_dir(dir) ⇒ Object



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

def load_plugin_dir(dir)
  dir = File.expand_path(dir)
  Dir.entries(dir).sort.each {|fname|
    if fname =~ /\.rb$/
      require File.join(dir, fname)
    end
  }
  nil
end

#load_pluginsObject



80
81
82
83
# File 'lib/fluent/plugin.rb', line 80

def load_plugins
  dir = File.join(File.dirname(__FILE__), "plugin")
  load_plugin_dir(dir)
end

#lookup_name_from_class(klass_or_str) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fluent/plugin.rb', line 99

def lookup_name_from_class(klass_or_str)
  klass = if klass_or_str.class == String
            eval(klass_or_str) # const_get can't handle A::B
          else
            klass_or_str
          end

  @input.each { |name, plugin|
    return name if plugin == klass
  }
  @output.each { |name, plugin|
    return name if plugin == klass
  }
  @filter.each { |name, plugin|
    return name if plugin == klass
  }

  nil
end

#new_buffer(type) ⇒ Object



66
67
68
# File 'lib/fluent/plugin.rb', line 66

def new_buffer(type)
  new_impl('buffer', @buffer, type)
end

#new_filter(type) ⇒ Object



62
63
64
# File 'lib/fluent/plugin.rb', line 62

def new_filter(type)
  new_impl('filter', @filter, type)
end

#new_formatter(type) ⇒ Object



75
76
77
78
# File 'lib/fluent/plugin.rb', line 75

def new_formatter(type)
  require 'fluent/formatter'
  TextFormatter.lookup(type)
end

#new_input(type) ⇒ Object



54
55
56
# File 'lib/fluent/plugin.rb', line 54

def new_input(type)
  new_impl('input', @input, type)
end

#new_output(type) ⇒ Object



58
59
60
# File 'lib/fluent/plugin.rb', line 58

def new_output(type)
  new_impl('output', @output, type)
end

#new_parser(type) ⇒ Object



70
71
72
73
# File 'lib/fluent/plugin.rb', line 70

def new_parser(type)
  require 'fluent/parser'
  TextParser.lookup(type)
end

#register_buffer(type, klass) ⇒ Object



42
43
44
# File 'lib/fluent/plugin.rb', line 42

def register_buffer(type, klass)
  register_impl('buffer', @buffer, type, klass)
end

#register_filter(type, klass) ⇒ Object



38
39
40
# File 'lib/fluent/plugin.rb', line 38

def register_filter(type, klass)
  register_impl('filter', @filter, type, klass)
end

#register_formatter(type, klass) ⇒ Object



50
51
52
# File 'lib/fluent/plugin.rb', line 50

def register_formatter(type, klass)
  TextFormatter.register_template(type, klass)
end

#register_input(type, klass) ⇒ Object



30
31
32
# File 'lib/fluent/plugin.rb', line 30

def register_input(type, klass)
  register_impl('input', @input, type, klass)
end

#register_output(type, klass) ⇒ Object



34
35
36
# File 'lib/fluent/plugin.rb', line 34

def register_output(type, klass)
  register_impl('output', @output, type, klass)
end

#register_parser(type, klass) ⇒ Object



46
47
48
# File 'lib/fluent/plugin.rb', line 46

def register_parser(type, klass)
  TextParser.register_template(type, klass)
end