From ff7b92ffc8e3a204c47584086569e8ad8b2799e4 Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Thu, 16 Jun 2011 17:24:15 -0700 Subject: [PATCH] Fixing bug with logging &optional records. Closes #476. --- src/LogMgr.cc | 2 +- .../Baseline/logging.unset-record/testing.log | 3 ++ testing/btest/logging/unset-record.log | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 testing/btest/Baseline/logging.unset-record/testing.log create mode 100644 testing/btest/logging/unset-record.log diff --git a/src/LogMgr.cc b/src/LogMgr.cc index 834829591a..6a23728ac0 100644 --- a/src/LogMgr.cc +++ b/src/LogMgr.cc @@ -1089,7 +1089,7 @@ LogVal** LogMgr::RecordToFilterVals(Stream* stream, Filter* filter, if ( ! val ) { // 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; } } diff --git a/testing/btest/Baseline/logging.unset-record/testing.log b/testing/btest/Baseline/logging.unset-record/testing.log new file mode 100644 index 0000000000..34f20a588b --- /dev/null +++ b/testing/btest/Baseline/logging.unset-record/testing.log @@ -0,0 +1,3 @@ +# a.val1 a.val2 b +- - 6 +1 2 3 diff --git a/testing/btest/logging/unset-record.log b/testing/btest/logging/unset-record.log new file mode 100644 index 0000000000..e4c05aec0f --- /dev/null +++ b/testing/btest/logging/unset-record.log @@ -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); +}