Skip to content

Commit

Permalink
fix(userspace/engine): base64 format fix
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
  • Loading branch information
2 people authored and poiana committed Feb 4, 2020
1 parent 22a9579 commit 240f7e2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions userspace/engine/formats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ int falco_formats::format_event (lua_State *ls)
if(strcmp(source, "syscall") == 0)
{
try {
// This is "output"
s_formatters->tostring((sinsp_evt *) evt, sformat, &line);

if(s_json_output)
{
switch(s_inspector->get_buffer_format())
sinsp_evt::param_fmt cur_fmt = s_inspector->get_buffer_format();
switch(cur_fmt)
{
case sinsp_evt::PF_NORMAL:
s_inspector->set_buffer_format(sinsp_evt::PF_JSON);
Expand All @@ -171,15 +173,15 @@ int falco_formats::format_event (lua_State *ls)
// do nothing
break;
}
// This is output fields
s_formatters->tostring((sinsp_evt *) evt, sformat, &json_line);

// The formatted string might have a leading newline. If it does, remove it.
if (json_line[0] == '\n')
{
json_line.erase(0, 1);
}

s_inspector->set_buffer_format(sinsp_evt::PF_NORMAL);
s_inspector->set_buffer_format(cur_fmt);
}
}
catch (sinsp_exception& e)
Expand Down

0 comments on commit 240f7e2

Please sign in to comment.