mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Merge remote-tracking branch 'origin/topic/dev/non-ascii-logging'
* origin/topic/dev/non-ascii-logging: Removed Policy Script for UTF-8 Logs Commented out UTF-8 Script in Test All Policy Minor Style Tweak Use getNumBytesForUTF8 method to determine number of bytes Added Jon's test cases as unit tests Prioritizes escaping predefined Escape Sequences over Unescaping UTF-8 Sequences Added additional check to confirm anything unescaping is a multibyte UTF-8 sequence, addressing the test case Jon brought up Added optional script and redef bool to enable utf-8 in ASCII logs Initial Commit, removed std::isprint check to escape Made minor code format and logic adjustments during merge.
This commit is contained in:
commit
d1770853b3
16 changed files with 181 additions and 3 deletions
|
@ -23,6 +23,7 @@ Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
|
|||
include_meta = false;
|
||||
tsv = false;
|
||||
use_json = false;
|
||||
enable_utf_8 = false;
|
||||
formatter = 0;
|
||||
gzip_level = 0;
|
||||
gzfile = nullptr;
|
||||
|
@ -36,6 +37,7 @@ void Ascii::InitConfigOptions()
|
|||
output_to_stdout = BifConst::LogAscii::output_to_stdout;
|
||||
include_meta = BifConst::LogAscii::include_meta;
|
||||
use_json = BifConst::LogAscii::use_json;
|
||||
enable_utf_8 = BifConst::LogAscii::enable_utf_8;
|
||||
gzip_level = BifConst::LogAscii::gzip_level;
|
||||
|
||||
separator.assign(
|
||||
|
@ -115,6 +117,19 @@ bool Ascii::InitFilterOptions()
|
|||
}
|
||||
}
|
||||
|
||||
else if ( strcmp(i->first, "enable_utf_8") == 0 )
|
||||
{
|
||||
if ( strcmp(i->second, "T") == 0 )
|
||||
enable_utf_8 = true;
|
||||
else if ( strcmp(i->second, "F") == 0 )
|
||||
enable_utf_8 = false;
|
||||
else
|
||||
{
|
||||
Error("invalid value for 'enable_utf_8', must be a string and either \"T\" or \"F\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
else if ( strcmp(i->first, "output_to_stdout") == 0 )
|
||||
{
|
||||
if ( strcmp(i->second, "T") == 0 )
|
||||
|
@ -181,6 +196,10 @@ bool Ascii::InitFormatter()
|
|||
}
|
||||
else
|
||||
{
|
||||
// Enable utf-8 if needed
|
||||
if ( enable_utf_8 )
|
||||
desc.EnableUTF8();
|
||||
|
||||
// Use the default "Bro logs" format.
|
||||
desc.EnableEscaping();
|
||||
desc.AddEscapeSequence(separator);
|
||||
|
|
|
@ -65,6 +65,7 @@ private:
|
|||
|
||||
int gzip_level; // level > 0 enables gzip compression
|
||||
bool use_json;
|
||||
bool enable_utf_8;
|
||||
string json_timestamps;
|
||||
|
||||
threading::formatter::Formatter* formatter;
|
||||
|
|
|
@ -11,5 +11,6 @@ const set_separator: string;
|
|||
const empty_field: string;
|
||||
const unset_field: string;
|
||||
const use_json: bool;
|
||||
const enable_utf_8: bool;
|
||||
const json_timestamps: JSON::TimestampFormat;
|
||||
const gzip_level: count;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue