mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
logging: Introduce Log::default_logdir deprecate LogAscii::logdir and per writer logdir
Also modify FormatRotationPath to keep rotated logs within Log::default_logdir unless the rotation function explicitly set dir, e.g. by when the user redef'ed default_rotation_interval.
This commit is contained in:
parent
513ea7e04f
commit
aaa47a709c
15 changed files with 272 additions and 5 deletions
|
@ -1529,6 +1529,13 @@ std::string Manager::FormatRotationPath(EnumValPtr writer, std::string_view path
|
|||
auto prefix = rp_val->GetFieldAs<StringVal>(1)->CheckString();
|
||||
auto dir = dir_val->AsString()->CheckString();
|
||||
|
||||
// If rotation_format_func returned an empty dir in RotationPath
|
||||
// and Log::default_logdir is set, use it so that rotation is
|
||||
// confined within it.
|
||||
auto default_logdir = zeek::id::find_const<StringVal>("Log::default_logdir")->ToStdString();
|
||||
if ( util::streq(dir, "") && ! default_logdir.empty() )
|
||||
dir = default_logdir.c_str();
|
||||
|
||||
if ( ! util::streq(dir, "") && ! util::detail::ensure_intermediate_dirs(dir) )
|
||||
{
|
||||
reporter->Error("Failed to create dir '%s' returned by "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue