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
51
52
53
|
# File 'lib/fluent/plugin/parser_jsonish.rb', line 51
def initialize
super
end
|
Instance Method Details
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
|
# File 'lib/fluent/plugin/parser_jsonish.rb', line 55
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
end
|
#parse(text) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/fluent/plugin/parser_jsonish.rb', line 100
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
@move_keys.map do |k,v|
record[v] = record.delete(k)
end
record.delete(nil)
yield time, record
end
end
|