printf Parser Module
See: http://www.cplusplus.com/reference/cstdio/printf/
1. Variables
- none
2. Functions
2.1. build_grammar
Constructs an LPEG grammar based on the printf format/args array.
Arguments
- t (array) - Column one is the format string and the additional columns are the
capture names of the arguments. Capture names starting with an
@
are lpeg.re expressions so the default parser for a type can be overridden when necessary.
Return
- grammar (LPEG user data object) or an error is thrown
2.2. load_messages
Compile the provide list of printf_messages into the grammars table.
Arguments
printf_messages (array) - array of printf message specifications to be compiled into grammars
printf_messages = { -- array (string and/or array) the order specified here is the load and evaluation order. -- string: name of a module containing a `printf_messages` array to import -- array: creates an on the fly grammar using a printf format specifications. -- see: https://mozilla-services.github.io/lua_sandbox_extensions/lpeg/modules/lpeg/printf.html {"%s:%lu: invalid line", "path", "linenum"}, "lpeg.openssh_portable", -- must export a `printf_messages` array }
- grammars (array/nil) - optional existing grammar array to append to
- grammars_size (number/nil) - number of items in the array
- module (string/nil) - identifer to help locate errors in nested includes
Return
- grammars (array) or an error is thrown
2.3. match_sample
Finds the grammar associated with the specified log message.
Arguments
- grammars (array) - Output from load_printf_grammars
Return
- grammar (userdata/nil) - Best match for the sample input or nil if no match is found
source code: printf.lua