Merge pull request #2862 from tclinken/set-log-group-with-open-trace-file

Allow trace log group to be set after database is created
This commit is contained in:
A.J. Beamon 2020-03-26 12:00:03 -07:00 committed by GitHub
commit 66786790ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 5 deletions

View File

@ -842,7 +842,7 @@ const UniqueOrderedOptionList<FDBTransactionOptions>& Database::getTransactionDe
void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> value) {
switch(option) {
// SOMEDAY: If the network is already started, should these three throw an error?
// SOMEDAY: If the network is already started, should these four throw an error?
case FDBNetworkOptions::TRACE_ENABLE:
networkOptions.traceDirectory = value.present() ? value.get().toString() : "";
break;
@ -854,10 +854,6 @@ void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> valu
validateOptionValue(value, true);
networkOptions.traceMaxLogsSize = extractIntOption(value, 0, std::numeric_limits<int64_t>::max());
break;
case FDBNetworkOptions::TRACE_LOG_GROUP:
if(value.present())
networkOptions.traceLogGroup = value.get().toString();
break;
case FDBNetworkOptions::TRACE_FORMAT:
validateOptionValue(value, true);
networkOptions.traceFormat = value.get().toString();
@ -866,6 +862,17 @@ void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> valu
throw invalid_option_value();
}
break;
case FDBNetworkOptions::TRACE_LOG_GROUP:
if(value.present()) {
if (traceFileIsOpen()) {
setTraceLogGroup(value.get().toString());
}
else {
networkOptions.traceLogGroup = value.get().toString();
}
}
break;
case FDBNetworkOptions::TRACE_CLOCK_SOURCE:
validateOptionValue(value, true);
networkOptions.traceClockSource = value.get().toString();

View File

@ -550,6 +550,11 @@ public:
}
}
void setLogGroup(const std::string& logGroup) {
MutexHolder holder(mutex);
this->logGroup = logGroup;
}
Future<Void> pingWriterThread() {
auto ping = new WriterThread::Ping;
auto f = ping->ack.getFuture();
@ -750,6 +755,10 @@ void removeTraceRole(std::string role) {
g_traceLog.removeRole(role);
}
void setTraceLogGroup(const std::string& logGroup) {
g_traceLog.setLogGroup(logGroup);
}
TraceEvent::TraceEvent() : initialized(true), enabled(false), logged(true) {}
TraceEvent::TraceEvent(TraceEvent &&ev) {

View File

@ -608,6 +608,7 @@ bool validateTraceClockSource(std::string source);
void addTraceRole(std::string role);
void removeTraceRole(std::string role);
void retriveTraceLogIssues(std::set<std::string>& out);
void setTraceLogGroup(const std::string& role);
template <class T>
struct Future;
struct Void;