Class: Fluent::TextParser::JSONishParser
- Inherits:
-
JSONParser
- Object
- JSONParser
- Fluent::TextParser::JSONishParser
show all
- Defined in:
- lib/fluent/plugin/parser_jsonish.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of JSONishParser.
50
51
52
|
# File 'lib/fluent/plugin/parser_jsonish.rb', line 50
def initialize
super
end
|
Instance Method Details
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/fluent/plugin/parser_jsonish.rb', line 54
def configure(conf)
if conf['time_format']
tmp_time_format = conf['time_format']
conf.delete('time_format')
end
super(conf)
@time_parser = StdFormatTimeParser.new(tmp_time_format)
@mutex = Mutex.new
@time_format = 'ignore_me'
@transforms = []
@maps.each do |elem|
if elem.is_a?(Array)
@transforms << [ Regexp.new(elem[0]), elem[1] ]
elsif elem.is_a?(String)
if elem == 'slashes'
@transforms << [ Regexp.new("\\\\"), "\\\\\\" ]
elsif elem == 'nulls'
@null_maps.each do |e|
@transforms << [ Regexp.new(sprintf(e[0],@null_pattern)), e[1] ]
end
else
raise ConfigError, "Unknown transform #{elem}."
end
else
raise ConfigError, "Unknown transform data type."
end
end
@message_key = conf['message_key']
@add_full_message = conf['add_full_message']
end
|
#parse(text) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/fluent/plugin/parser_jsonish.rb', line 102
def parse(text)
full_message = @add_full_message ? text : nil
@transforms.each do |args|
text.gsub!(*args)
end
super(text) do |time,record|
if @message_key
record['message'] = record[@message_key]
end
if full_message
record['full_message'] = full_message
end
yield time, record
end
end
|