mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Renaming ASCII writer filter option 'only_single_header_row' to 'tsv'.
Also clarifying usage. Closes #912.
This commit is contained in:
parent
d9f90fcac0
commit
63d43e6545
7 changed files with 23 additions and 15 deletions
5
CHANGES
5
CHANGES
|
@ -1,4 +1,9 @@
|
|||
|
||||
2.1-194 | 2012-12-03 14:36:26 -0800
|
||||
|
||||
* Renaming ASCII writer filter option 'only_single_header_row' to
|
||||
'tsv'. Also clarifying usage. Closes #912. (Robin Sommer)
|
||||
|
||||
2.1-193 | 2012-12-03 14:11:14 -0800
|
||||
|
||||
* Fix a set of bugs with table/set attributes. (Jon Siwek)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.1-193
|
||||
2.1-194
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
##! to tweak the output format of ASCII logs.
|
||||
##!
|
||||
##! The ASCII writer supports currently one writer-specific filter option via
|
||||
##! ``config``: setting ``only_single_header_row`` to ``T`` turns the output into
|
||||
##! into CSV mode where only a single header row with the column names is printed
|
||||
##! out as meta information. Example filter using this::
|
||||
##! ``config``: setting ``tsv`` to the string ``T`` turns the output into into
|
||||
##! "tab-separated-value" mode where only a single header row with the column names
|
||||
##! is printed out as meta information, with no "# fields" prepended; no other meta
|
||||
##! data gets included in that mode.
|
||||
##!
|
||||
##! local my_filter: Log::Filter = [$name = "my-filter", $writer = Log::WRITER_ASCII, $config = table(["only_single_header_row"] = "T")];
|
||||
##! Example filter using this::
|
||||
##!
|
||||
##! local my_filter: Log::Filter = [$name = "my-filter", $writer = Log::WRITER_ASCII, $config = table(["tsv"] = "T")];
|
||||
##!
|
||||
|
||||
module LogAscii;
|
||||
|
|
|
@ -19,7 +19,7 @@ Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
|
|||
{
|
||||
fd = 0;
|
||||
ascii_done = false;
|
||||
only_single_header_row = false;
|
||||
tsv = false;
|
||||
|
||||
output_to_stdout = BifConst::LogAscii::output_to_stdout;
|
||||
include_meta = BifConst::LogAscii::include_meta;
|
||||
|
@ -81,7 +81,7 @@ void Ascii::CloseFile(double t)
|
|||
if ( ! fd )
|
||||
return;
|
||||
|
||||
if ( include_meta && ! only_single_header_row )
|
||||
if ( include_meta && ! tsv )
|
||||
WriteHeaderField("close", Timestamp(0));
|
||||
|
||||
safe_close(fd);
|
||||
|
@ -111,17 +111,17 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const Field* const *
|
|||
|
||||
for ( WriterInfo::config_map::const_iterator i = info.config.begin(); i != info.config.end(); i++ )
|
||||
{
|
||||
if ( strcmp(i->first, "only_single_header_row") == 0 )
|
||||
if ( strcmp(i->first, "tsv") == 0 )
|
||||
{
|
||||
if ( strcmp(i->second, "T") == 0 )
|
||||
only_single_header_row = true;
|
||||
tsv = true;
|
||||
|
||||
else if ( strcmp(i->second, "F") == 0 )
|
||||
only_single_header_row = false;
|
||||
tsv = false;
|
||||
|
||||
else
|
||||
{
|
||||
Error("invalid value for 'only_single_header_row', must be boolean (T/F)");
|
||||
Error("invalid value for 'tsv', must be a string and either \"T\" or \"F\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -144,9 +144,9 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const Field* const *
|
|||
types += fields[i]->TypeName().c_str();
|
||||
}
|
||||
|
||||
if ( only_single_header_row )
|
||||
if ( tsv )
|
||||
{
|
||||
// A single CSV-style line is all we need.
|
||||
// A single TSV-style line is all we need.
|
||||
string str = names + "\n";
|
||||
if ( ! safe_write(fd, str.c_str(), str.length()) )
|
||||
goto write_error;
|
||||
|
|
|
@ -45,7 +45,7 @@ private:
|
|||
// Options set from the script-level.
|
||||
bool output_to_stdout;
|
||||
bool include_meta;
|
||||
bool only_single_header_row;
|
||||
bool tsv;
|
||||
|
||||
char* separator;
|
||||
int separator_len;
|
||||
|
|
|
@ -22,7 +22,7 @@ event bro_init()
|
|||
Log::create_stream(SSH::LOG, [$columns=Log]);
|
||||
|
||||
local filter = Log::get_filter(SSH::LOG, "default");
|
||||
filter$config = table(["only_single_header_row"] = "T");
|
||||
filter$config = table(["tsv"] = "T");
|
||||
Log::add_filter(SSH::LOG, filter);
|
||||
|
||||
local cid = [$orig_h=1.2.3.4, $orig_p=1234/tcp, $resp_h=2.3.4.5, $resp_p=80/tcp];
|
Loading…
Add table
Add a link
Reference in a new issue