mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 04:58:21 +00:00
Merge branch 'logging/script-logdir' of https://github.com/kramse/zeek
* 'logging/script-logdir' of https://github.com/kramse/zeek: Copy of ascii-empty test, just changed path in the beginning Logdir: Change requested by 0xxon, no problem Introduce script-land variable that can be used to set logdir. Closes GH-772
This commit is contained in:
commit
e0d284ec9f
9 changed files with 91 additions and 2 deletions
|
@ -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,19 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const threading::Fiel
|
|||
ext += gzip_file_extension.empty() ? "gz" : gzip_file_extension;
|
||||
}
|
||||
|
||||
if ( fname.front() != '/' && ! logdir.empty() )
|
||||
{
|
||||
string path = logdir;
|
||||
std::size_t last = path.find_last_not_of('/');
|
||||
|
||||
if ( last == string::npos ) // Nothing but slashes -- weird but ok...
|
||||
path = "/";
|
||||
else
|
||||
path.erase(last + 1);
|
||||
|
||||
fname = path + "/" + fname;
|
||||
}
|
||||
|
||||
fname += ext;
|
||||
|
||||
bool use_shadow = BifConst::LogAscii::enable_leftover_log_rotation && Info().rotation_interval > 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue