diff options
author | Benety Goh <benety@mongodb.com> | 2014-08-27 14:43:25 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2014-08-28 13:44:47 -0400 |
commit | ac6b4eac9d1fc33d357ee9264e4508f8a564d89d (patch) | |
tree | c9cf8b5706ed7ebc300de1f9cca9ff25d944a494 /src/mongo/db/commands/parameters.cpp | |
parent | 6250f6da8b0713759a402caef66c110822361390 (diff) | |
download | mongo-ac6b4eac9d1fc33d357ee9264e4508f8a564d89d.tar.gz |
SERVER-15045 extend logComponentVerbosity to support less verbose BSON format for log component severity
Diffstat (limited to 'src/mongo/db/commands/parameters.cpp')
-rw-r--r-- | src/mongo/db/commands/parameters.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp index 280ebf7f165..3fb38a28024 100644 --- a/src/mongo/db/commands/parameters.cpp +++ b/src/mongo/db/commands/parameters.cpp @@ -317,18 +317,38 @@ namespace mongo { * verbosity: -1, <-- clears componentA.componentC's log level so that * its final loglevel will be inherited from componentA. * } - * } + * }, + * componentD : 3 <-- sets componentD's log level to 3 (alternative to + * subdocument with 'verbosity' field). * } * + * For the default component, the log level is read from the top-level + * "verbosity" field. + * For non-default components, we look up the element using the component's + * dotted name. If the "<dotted component name>" field is a number, the log + * level will be read from the field's value. + * Otherwise, we assume that the "<dotted component name>" field is an + * object with a "verbosity" field that holds the log level for the component. + * The more verbose format with the "verbosity" field is intended to support + * setting of log levels of both parent and child log components in the same + * BSON document. + * * Ignore elements in BSON object that do not map to a log component's dotted * name. */ Status _set(const BSONObj& obj) const { for (int i = 0; i < int(logger::LogComponent::kNumLogComponents); ++i) { logger::LogComponent component = static_cast<logger::LogComponent::Value>(i); - const string fieldName = component == logger::LogComponent::kDefault ? - "verbosity" : (component.getDottedName() + ".verbosity"); - BSONElement element = obj.getFieldDotted(fieldName); + BSONElement element; + if (component == logger::LogComponent::kDefault) { + element = obj.getField("verbosity"); + } + else { + element = obj.getFieldDotted(component.getDottedName()); + if (!element.isNumber()) { + element = obj.getFieldDotted(component.getDottedName() + ".verbosity"); + } + } if (element.eoo()) { continue; } |