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)
|
bool LogField::Read(SerializationFormat* fmt)
|
||||||
{
|
{
|
||||||
int t;
|
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;
|
type = (TypeTag) t;
|
||||||
|
subtype = (TypeTag) st;
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LogField::Write(SerializationFormat* fmt) const
|
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()
|
LogVal::~LogVal()
|
||||||
|
@ -707,6 +709,14 @@ bool LogMgr::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
||||||
LogField* field = new LogField();
|
LogField* field = new LogField();
|
||||||
field->name = new_path;
|
field->name = new_path;
|
||||||
field->type = t->Tag();
|
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;
|
filter->fields[filter->num_fields - 1] = field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,12 @@ class SerializationFormat;
|
||||||
struct LogField {
|
struct LogField {
|
||||||
string name;
|
string name;
|
||||||
TypeTag type;
|
TypeTag type;
|
||||||
|
// inner type of sets
|
||||||
|
TypeTag subtype;
|
||||||
|
|
||||||
LogField() { }
|
LogField() { subtype = TYPE_VOID; }
|
||||||
LogField(const LogField& other)
|
LogField(const LogField& other)
|
||||||
: name(other.name), type(other.type) { }
|
: name(other.name), type(other.type), subtype(other.subtype) { }
|
||||||
|
|
||||||
// (Un-)serialize.
|
// (Un-)serialize.
|
||||||
bool Read(SerializationFormat* fmt);
|
bool Read(SerializationFormat* fmt);
|
||||||
|
|
|
@ -125,6 +125,12 @@ bool LogWriterAscii::DoInit(string path, int num_fields,
|
||||||
const LogField* field = fields[i];
|
const LogField* field = fields[i];
|
||||||
names += field->name;
|
names += field->name;
|
||||||
types += type_name(field->type);
|
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)
|
if ( ! (WriteHeaderField("fields", names)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue