mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Introduce script-land variable that can be used to set logdir.
Addresses GH-772
This commit is contained in:
parent
672504e265
commit
6bde33aca7
4 changed files with 22 additions and 1 deletions
|
@ -54,6 +54,11 @@ export {
|
|||
## This option is also available as a per-filter ``$config`` option.
|
||||
const gzip_file_extension = "gz" &redef;
|
||||
|
||||
## Default logs to current directory
|
||||
## Can be redefined to send files into logging directory
|
||||
##
|
||||
const logdir = "." &redef;
|
||||
|
||||
## Format of timestamps when writing out JSON. By default, the JSON
|
||||
## formatter will use double values for timestamps which represent the
|
||||
## number of seconds from the UNIX epoch.
|
||||
|
|
|
@ -252,6 +252,12 @@ void Ascii::InitConfigOptions()
|
|||
(const char*) BifConst::LogAscii::gzip_file_extension->Bytes(),
|
||||
BifConst::LogAscii::gzip_file_extension->Len()
|
||||
);
|
||||
|
||||
logdir.assign(
|
||||
(const char*) BifConst::LogAscii::logdir->Bytes(),
|
||||
BifConst::LogAscii::logdir->Len()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
bool Ascii::InitFilterOptions()
|
||||
|
@ -344,6 +350,9 @@ bool Ascii::InitFilterOptions()
|
|||
|
||||
else if ( strcmp(i->first, "gzip_file_extension") == 0 )
|
||||
gzip_file_extension.assign(i->second);
|
||||
|
||||
else if ( strcmp(i->first, "logdir") == 0 )
|
||||
logdir.assign(i->second);
|
||||
}
|
||||
|
||||
if ( ! InitFormatter() )
|
||||
|
@ -448,6 +457,11 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const threading::Fiel
|
|||
ext += gzip_file_extension.empty() ? "gz" : gzip_file_extension;
|
||||
}
|
||||
|
||||
if ( ! logdir.empty() )
|
||||
{
|
||||
fname = logdir.empty() ? fname : logdir + "/" + fname;
|
||||
}
|
||||
|
||||
fname += ext;
|
||||
|
||||
bool use_shadow = BifConst::LogAscii::enable_leftover_log_rotation && Info().rotation_interval > 0;
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
bool use_json;
|
||||
bool enable_utf_8;
|
||||
std::string json_timestamps;
|
||||
std::string logdir;
|
||||
|
||||
threading::Formatter* formatter;
|
||||
bool init_options;
|
||||
|
|
|
@ -16,3 +16,4 @@ const enable_utf_8: bool;
|
|||
const json_timestamps: JSON::TimestampFormat;
|
||||
const gzip_level: count;
|
||||
const gzip_file_extension: string;
|
||||
const logdir: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue