Skip to content

Commit

Permalink
wsd: use the 'flush' logging property to disable buffering
Browse files Browse the repository at this point in the history
In some cases it's benefitial to disable buffered-
logging and flush after each entry is generated.

We already have an unbuffered logger and a
property, called 'flush', already exists and
is used by Poco to also disable buffering its
file-logger.

We leverage this property to disable buffering
in both the console logger (this patch), as well
as in Poco's file-logger (existing functionality).

Change-Id: I5e3b75e66f82a8a5df57901ef4f6c8264aee3565
Signed-off-by: Ashod Nakashian <[email protected]>
  • Loading branch information
Ashod authored and mmeeks committed Nov 4, 2024
1 parent 23a0a45 commit 384ba58
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion common/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,17 @@ namespace Log
}
else
{
channel = static_cast<Poco::Channel*>(new Log::BufferedConsoleChannel());
const auto it = config.find("flush");
if (it != config.end() && Util::toLower(it->second) != "false")
{
// Buffered logging, reduces number of write(2) syscalls.
channel = static_cast<Poco::Channel*>(new Log::BufferedConsoleChannel());
}
else
{
// Unbuffered logging, directly writes each entry (to stderr).
channel = static_cast<Poco::Channel*>(new Log::ConsoleChannel());
}
}

/**
Expand Down

0 comments on commit 384ba58

Please sign in to comment.