mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Don't redirect audit.log output with -printtoconsole
This commit is contained in:
parent
da26d4e9cc
commit
7447486cb0
1 changed files with 16 additions and 26 deletions
42
src/util.cpp
42
src/util.cpp
|
|
@ -373,35 +373,25 @@ int AuditLogPrintStr(const std::string &str)
|
|||
|
||||
string strTimestamped = LogTimestampStr(str, &fStartedNewLine);
|
||||
|
||||
if (fPrintToConsole)
|
||||
{
|
||||
// print to console
|
||||
ret = fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout);
|
||||
fflush(stdout);
|
||||
boost::call_once(&AuditPrintInit, auditPrintInitFlag);
|
||||
boost::mutex::scoped_lock scoped_lock(*mutexAuditLog);
|
||||
|
||||
// buffer if we haven't opened the log yet
|
||||
if (fileout_audit == NULL) {
|
||||
assert(vMsgsBeforeOpenAuditLog);
|
||||
ret = strTimestamped.length();
|
||||
vMsgsBeforeOpenAuditLog->push_back(strTimestamped);
|
||||
}
|
||||
else if (fPrintToAuditLog)
|
||||
else
|
||||
{
|
||||
boost::call_once(&AuditPrintInit, auditPrintInitFlag);
|
||||
boost::mutex::scoped_lock scoped_lock(*mutexAuditLog);
|
||||
|
||||
// buffer if we haven't opened the log yet
|
||||
if (fileout_audit == NULL) {
|
||||
assert(vMsgsBeforeOpenAuditLog);
|
||||
ret = strTimestamped.length();
|
||||
vMsgsBeforeOpenAuditLog->push_back(strTimestamped);
|
||||
}
|
||||
else
|
||||
{
|
||||
// reopen the log file, if requested
|
||||
if (fReopenAuditLog) {
|
||||
fReopenAuditLog = false;
|
||||
boost::filesystem::path pathAudit = GetDataDir() / "audit.log";
|
||||
if (freopen(pathAudit.string().c_str(),"a",fileout_audit) != NULL)
|
||||
setbuf(fileout_audit, NULL); // unbuffered
|
||||
}
|
||||
|
||||
ret = FileWriteStr(strTimestamped, fileout_audit);
|
||||
// reopen the log file, if requested
|
||||
if (fReopenAuditLog) {
|
||||
fReopenAuditLog = false;
|
||||
boost::filesystem::path pathAudit = GetDataDir() / "audit.log";
|
||||
if (freopen(pathAudit.string().c_str(),"a",fileout_audit) != NULL)
|
||||
setbuf(fileout_audit, NULL); // unbuffered
|
||||
}
|
||||
ret = FileWriteStr(strTimestamped, fileout_audit);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue