mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
make LogWriter output the type of data stored inside a set or vector.
Now the type output is e.g. vector[string] instead of just vector.
This commit is contained in:
parent
f1e132cd1a
commit
e114bdf627
3 changed files with 22 additions and 4 deletions
|
@ -81,16 +81,18 @@ struct LogMgr::Stream {
|
|||
bool LogField::Read(SerializationFormat* fmt)
|
||||
{
|
||||
int t;
|
||||
int st;
|
||||
|
||||
bool success = (fmt->Read(&name, "name") && fmt->Read(&t, "type"));
|
||||
bool success = (fmt->Read(&name, "name") && fmt->Read(&t, "type") && fmt->Read(&st, "subtype") );
|
||||
type = (TypeTag) t;
|
||||
subtype = (TypeTag) st;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool LogField::Write(SerializationFormat* fmt) const
|
||||
{
|
||||
return (fmt->Write(name, "name") && fmt->Write((int)type, "type"));
|
||||
return (fmt->Write(name, "name") && fmt->Write((int)type, "type") && fmt->Write((int)subtype, "subtype"));
|
||||
}
|
||||
|
||||
LogVal::~LogVal()
|
||||
|
@ -707,6 +709,14 @@ bool LogMgr::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
|||
LogField* field = new LogField();
|
||||
field->name = new_path;
|
||||
field->type = t->Tag();
|
||||
if ( field->type == TYPE_TABLE )
|
||||
{
|
||||
field->subtype = t->AsSetType()->Indices()->PureType()->Tag();
|
||||
}
|
||||
else if ( field->type == TYPE_VECTOR )
|
||||
{
|
||||
field->subtype = t->AsVectorType()->YieldType()->Tag();
|
||||
}
|
||||
filter->fields[filter->num_fields - 1] = field;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,12 @@ class SerializationFormat;
|
|||
struct LogField {
|
||||
string name;
|
||||
TypeTag type;
|
||||
// inner type of sets
|
||||
TypeTag subtype;
|
||||
|
||||
LogField() { }
|
||||
LogField() { subtype = TYPE_VOID; }
|
||||
LogField(const LogField& other)
|
||||
: name(other.name), type(other.type) { }
|
||||
: name(other.name), type(other.type), subtype(other.subtype) { }
|
||||
|
||||
// (Un-)serialize.
|
||||
bool Read(SerializationFormat* fmt);
|
||||
|
|
|
@ -125,6 +125,12 @@ bool LogWriterAscii::DoInit(string path, int num_fields,
|
|||
const LogField* field = fields[i];
|
||||
names += field->name;
|
||||
types += type_name(field->type);
|
||||
if ( (field->type == TYPE_TABLE) || (field->type == TYPE_VECTOR) )
|
||||
{
|
||||
types += "[";
|
||||
types += type_name(field->subtype);
|
||||
types += "]";
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! (WriteHeaderField("fields", names)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue