summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@mongodb.com>2014-03-27 20:32:17 -0400
committerShaun Verch <shaun.verch@mongodb.com>2014-03-28 13:49:44 -0400
commit0c1fa12980c7b5489213f2349c0bc1f3d338c8f3 (patch)
tree569c10dca1984bf37467ccd7fff1d1e8709e1624
parent0d2fe93ded0fd0a8f5663ab9aa98ee45bd6068eb (diff)
downloadmongo-0c1fa12980c7b5489213f2349c0bc1f3d338c8f3.tar.gz
SERVER-13379 Canonicalize logpath as systemLog.destination and systemLog.path
(cherry picked from commit 064fcf3fec061e0f3493f813016ee96a3668d14d)
-rw-r--r--jstests/core/logging_options.js29
-rw-r--r--src/mongo/db/server_options_helpers.cpp30
2 files changed, 51 insertions, 8 deletions
diff --git a/jstests/core/logging_options.js b/jstests/core/logging_options.js
index 953dce5227d..b3d999a53a8 100644
--- a/jstests/core/logging_options.js
+++ b/jstests/core/logging_options.js
@@ -6,6 +6,7 @@ function removeOptionsAddedByFramework(getCmdLineOptsResult) {
delete getCmdLineOptsResult.parsed.storage
delete getCmdLineOptsResult.parsed.net
delete getCmdLineOptsResult.parsed.fastsync
+ delete getCmdLineOptsResult.parsed.security
return getCmdLineOptsResult;
}
@@ -28,6 +29,7 @@ function testGetCmdLineOpts(mongoRunnerConfig, expectedResult) {
MongoRunner.stopMongod(mongod.port);
}
+// Verbosity testing
jsTest.log("Testing \"verbose\" command line option with no args");
var expectedResult = {
"parsed" : {
@@ -91,10 +93,35 @@ expectedResult = {
};
testGetCmdLineOpts({ config : "jstests/libs/config_files/set_verbosity.json" }, expectedResult);
-jsTest.log("Testing with no explicit verbosity setting");
+
+
+// Log output testing
+var baseDir = MongoRunner.dataPath + baseName;
+var logDir = MongoRunner.dataPath + baseName + "/logs/";
+
+// ensure log directory exists
+assert(mkdir(baseDir));
+assert(mkdir(logDir));
+
+jsTest.log("Testing \"logpath\" command line option");
+var expectedResult = {
+ "parsed" : {
+ "systemLog" : {
+ "destination" : "file",
+ "path" : logDir + "/mylog.log"
+ }
+ }
+};
+testGetCmdLineOpts({ logpath : logDir + "/mylog.log" }, expectedResult);
+
+
+
+jsTest.log("Testing with no explicit logging setting");
expectedResult = {
"parsed" : { }
};
testGetCmdLineOpts({}, expectedResult);
+resetDbpath(baseDir);
+
print(baseName + " succeeded.");
diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp
index db9e31fe01b..da02c8064d3 100644
--- a/src/mongo/db/server_options_helpers.cpp
+++ b/src/mongo/db/server_options_helpers.cpp
@@ -499,6 +499,29 @@ namespace {
}
}
+ if (params->count("logpath")) {
+ std::string logpath;
+ Status ret = params->get("logpath", &logpath);
+ if (!ret.isOK()) {
+ return ret;
+ }
+ if (logpath.empty()) {
+ return Status(ErrorCodes::BadValue, "logpath cannot be empty if supplied");
+ }
+ ret = params->set("systemLog.destination", moe::Value(std::string("file")));
+ if (!ret.isOK()) {
+ return ret;
+ }
+ ret = params->set("systemLog.path", moe::Value(logpath));
+ if (!ret.isOK()) {
+ return ret;
+ }
+ ret = params->remove("logpath");
+ if (!ret.isOK()) {
+ return ret;
+ }
+ }
+
return Status::OK();
}
@@ -685,13 +708,6 @@ namespace {
}
- if (params.count("logpath")) {
- serverGlobalParams.logpath = params["logpath"].as<string>();
- if (serverGlobalParams.logpath.empty()) {
- return Status(ErrorCodes::BadValue, "logpath cannot be empty if supplied");
- }
- }
-
serverGlobalParams.logWithSyslog = params.count("systemLog.syslog");
#ifndef _WIN32