Files can now be logged; their filename will be written out.

This commit is contained in:
Robin Sommer 2011-04-17 20:52:18 -07:00
parent c132506203
commit 29b0d0d1d9
5 changed files with 45 additions and 2 deletions

View file

@ -65,7 +65,7 @@ struct LogMgr::Stream {
LogVal::~LogVal()
{
if ( (type == TYPE_ENUM || type == TYPE_STRING) && present )
if ( (type == TYPE_ENUM || type == TYPE_STRING || type == TYPE_FILE) && present )
delete val.string_val;
if ( type == TYPE_TABLE && present )
@ -104,6 +104,7 @@ bool LogVal::IsCompatibleType(BroType* t, bool atomic_only)
case TYPE_INTERVAL:
case TYPE_ENUM:
case TYPE_STRING:
case TYPE_FILE:
return true;
case TYPE_RECORD:
@ -206,6 +207,7 @@ bool LogVal::Read(SerializationFormat* fmt)
case TYPE_ENUM:
case TYPE_STRING:
case TYPE_FILE:
{
val.string_val = new string;
return fmt->Read(val.string_val, "string");
@ -309,6 +311,7 @@ bool LogVal::Write(SerializationFormat* fmt) const
case TYPE_ENUM:
case TYPE_STRING:
case TYPE_FILE:
return fmt->Write(*val.string_val, "string");
case TYPE_TABLE:
@ -574,6 +577,11 @@ bool LogMgr::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, Tabl
// That's ok, handle it with all the other types below.
}
else if ( t->Tag() == TYPE_FILE )
{
// That's ok, handle it with all the other types below.
}
else {
run_time("unsupported field type for log column");
return false;
@ -936,6 +944,13 @@ LogVal* LogMgr::ValToLogVal(Val* val, BroType* ty)
break;
}
case TYPE_FILE:
{
const BroFile* f = val->AsFile();
lval->val.string_val = new string(f->Name());
break;
}
case TYPE_TABLE:
{
ListVal* set = val->AsTableVal()->ConvertToPureList();