Skip to content

Commit

Permalink
Move the loading of the grammar to outside of the process_message fun…
Browse files Browse the repository at this point in the history
…ction so it's not re-initialized each time a log line is processed.
  • Loading branch information
nickchappell committed Jun 9, 2016
1 parent 91fa76e commit de8e6b5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sandbox/lua/decoders/bind_query_log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ local msg = {
Fields = {},
}

--Load the query log grammar from the bind module:
local grammar = l.Ct(bind.query_log_grammar)

function process_message ()

--Create a local variable for the log line from the Payload of the incoming Heka message.
--The LogstreamerInput that generates the messages automatically puts the
local query_log_line = read_message("Payload")
--Use the bind_query grammar defined farther above to create a local grammar object:
local grammar = l.Ct(bind.query_log_grammar)

--Create a fields table and use the :match method on the grammar object to fill it with the Lua table
--of values generated by parsing the query_log_line:
fields = grammar:match(query_log_line)
Expand Down

0 comments on commit de8e6b5

Please sign in to comment.