log_converter.lua

--- Parse a log line and return timestamp and message
-- @param log_line Line to be parsed
-- @return text The message part from the log line
-- @return timestamp string reprecenting the timesamp in second with the resouluton of µS.
function convert_log_line(log_line)

    local first = string.find(log_line, "%[")
    local last = string.find(log_line, "%]")

    if first == nil or last == nil then
        return log_line
    end

    local timestamp = string.sub(log_line, first+1, last-1)
    if tonumber(timestamp) == nil then
        return log_line
    end

    local text = string.sub(log_line, last+1)

    -- text, the message part as string
    -- timestamp, timestamp in seconds as string
    return text, timestamp
end

--- Short description of the timestamp conversion.
-- @return description
function convert_description()
    return "Converts log lines beginning with timestamp format: [    0.100353] in sec."
end
generated by LDoc 1.4.6 Last updated 2021-10-13 21:46:39