Fixing bug with logging &optional records.

Closes #476.
This commit is contained in:
Robin Sommer 2011-06-16 17:24:15 -07:00
parent 88509e2191
commit ff7b92ffc8
3 changed files with 32 additions and 1 deletions

View file

@ -1089,7 +1089,7 @@ LogVal** LogMgr::RecordToFilterVals(Stream* stream, Filter* filter,
if ( ! val ) if ( ! val )
{ {
// Value, or any of its parents, is not set. // Value, or any of its parents, is not set.
vals[i] = new LogVal(type, false); vals[i] = new LogVal(filter->fields[i]->type, false);
break; break;
} }
} }

View file

@ -0,0 +1,3 @@
# a.val1 a.val2 b
- - 6
1 2 3

View file

@ -0,0 +1,28 @@
#
# @TEST-EXEC: bro %INPUT
# @TEST-EXEC: btest-diff testing.log
redef enum Log::ID += { TESTING };
type Foo: record {
val1: count;
val2: count;
} &log;
type Bar: record {
a: Foo &log &optional;
b: count &log;
};
event bro_init()
{
Log::create_stream(TESTING, [$columns=Bar]);
local x: Bar;
x = [$b=6];
Log::write(TESTING, x);
x = [$a=[$val1=1,$val2=2], $b=3];
Log::write(TESTING, x);
}