You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 08:37:43 UTC
svn commit: r1131928 - /incubator/mesos/trunk/src/logging.cpp
Author: benh
Date: Sun Jun 5 06:37:43 2011
New Revision: 1131928
URL: http://svn.apache.org/viewvc?rev=1131928&view=rev
Log:
Made log location default to MESOS_HOME/logs, and to nothing if no
location is specified.
Modified:
incubator/mesos/trunk/src/logging.cpp
Modified: incubator/mesos/trunk/src/logging.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/logging.cpp?rev=1131928&r1=1131927&r2=1131928&view=diff
==============================================================================
--- incubator/mesos/trunk/src/logging.cpp (original)
+++ incubator/mesos/trunk/src/logging.cpp Sun Jun 5 06:37:43 2011
@@ -1,26 +1,33 @@
#include "logging.hpp"
+#include <sys/stat.h>
+
#include <glog/logging.h>
+#include "fatal.hpp"
+
using std::string;
using namespace mesos::internal;
-namespace {
-const string DEFAULT_LOG_DIR = "/tmp";
-}
-
void Logging::registerOptions(Configurator* conf)
{
conf->addOption<bool>("quiet", 'q', "Disable logging to stderr", false);
- conf->addOption<string>("log_dir", "Where to place logs", DEFAULT_LOG_DIR);
+ conf->addOption<string>("log_dir",
+ "Where to put logs (default: MESOS_HOME/logs)");
}
void Logging::init(const char* programName, const Params& conf)
{
// Set glog's parameters through Google Flags variables
- FLAGS_log_dir = conf.get("log_dir", DEFAULT_LOG_DIR);
+ string logDir = getLogDir(conf);
+ if (logDir != "") {
+ if (mkdir(logDir.c_str(), 0755) < 0 && errno != EEXIST) {
+ fatalerror("Failed to create log directory %s", logDir.c_str());
+ }
+ FLAGS_log_dir = logDir;
+ }
FLAGS_logbufsecs = 1;
google::InitGoogleLogging(programName);
@@ -31,7 +38,12 @@ void Logging::init(const char* programNa
string Logging::getLogDir(const Params& conf)
{
- return conf.get("log_dir", DEFAULT_LOG_DIR);
+ if (conf.contains("log_dir"))
+ return conf.get("log_dir", "");
+ else if (conf.contains("home"))
+ return conf.get("home", "") + "/logs";
+ else
+ return "";
}