Allow trace log group to be set after database is created

This commit is contained in:
tclinken 2020-03-25 13:27:56 -07:00
parent 0547cf2b4c
commit 7d5ed53215
3 changed files with 19 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,8 @@ public:
}
}
void setLogGroup(const std::string& logGroup) { this->logGroup = logGroup; }
Future<Void> pingWriterThread() {
auto ping = new WriterThread::Ping;
auto f = ping->ack.getFuture();
@ -750,6 +752,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;