Repository: mesos
Updated Branches:
  refs/heads/master b99ec4275 -> c624a97d3


Added a flag for specifying an externally managed log file.

Review: https://reviews.apache.org/r/30328


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c624a97d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c624a97d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c624a97d

Branch: refs/heads/master
Commit: c624a97d361860b86f8eb21e66bb42099bac8edc
Parents: b99ec42
Author: David Robinson <[email protected]>
Authored: Tue Jan 27 17:20:00 2015 -0800
Committer: Benjamin Mahler <[email protected]>
Committed: Tue Jan 27 17:20:03 2015 -0800

----------------------------------------------------------------------
 src/logging/flags.hpp                     | 11 ++++++++++-
 src/master/http.cpp                       |  4 ++++
 src/master/master.cpp                     | 10 +++++++++-
 src/slave/http.cpp                        |  4 ++++
 src/slave/slave.cpp                       | 10 +++++++++-
 src/webui/master/static/js/controllers.js |  8 ++++----
 6 files changed, 40 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c624a97d/src/logging/flags.hpp
----------------------------------------------------------------------
diff --git a/src/logging/flags.hpp b/src/logging/flags.hpp
index 11efb84..4facb33 100644
--- a/src/logging/flags.hpp
+++ b/src/logging/flags.hpp
@@ -49,7 +49,9 @@ public:
         "log_dir",
         "Directory path to put log files (no default, nothing\n"
         "is written to disk unless specified;\n"
-        "does not affect logging to stderr)");
+        "does not affect logging to stderr).\n"
+        "NOTE: 3rd party log messages (e.g. ZooKeeper) are\n"
+        "only written to stderr!\n");
 
     add(&Flags::logbufsecs,
         "logbufsecs",
@@ -61,6 +63,12 @@ public:
         "Whether to automatically initialize google logging of scheduler\n"
         "and/or executor drivers.",
         true);
+
+    add(&Flags::external_log_file,
+        "external_log_file",
+        "Specified the externally managed log file. This file will be\n"
+        "exposed in the webui and HTTP api. This is useful when using\n"
+        "stderr logging as the log file is otherwise unknown to Mesos.");
   }
 
   bool quiet;
@@ -68,6 +76,7 @@ public:
   Option<std::string> log_dir;
   int logbufsecs;
   bool initialize_driver_logging;
+  Option<std::string> external_log_file;
 };
 
 } // namespace logging {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c624a97d/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 46890be..3981b18 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -530,6 +530,10 @@ Future<Response> Master::Http::state(const Request& 
request)
     object.values["log_dir"] = master->flags.log_dir.get();
   }
 
+  if (master->flags.external_log_file.isSome()) {
+    object.values["external_log_file"] = master->flags.external_log_file.get();
+  }
+
   JSON::Object flags;
   foreachpair (const string& name, const flags::Flag& flag, master->flags) {
     Option<string> value = flag.stringify(master->flags);

http://git-wip-us.apache.org/repos/asf/mesos/blob/c624a97d/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index ab6d1d1..54f2690 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -626,7 +626,15 @@ void Master::initialize()
   provide("", path::join(flags.webui_dir, "master/static/index.html"));
   provide("static", path::join(flags.webui_dir, "master/static"));
 
-  if (flags.log_dir.isSome()) {
+  // Expose the log file for the webui. Fall back to 'log_dir' if
+  // an explicit file was not specified.
+  if (flags.external_log_file.isSome()) {
+    files->attach(flags.external_log_file.get(), "/master/log")
+      .onAny(defer(self(),
+                   &Self::fileAttached,
+                   lambda::_1,
+                   flags.external_log_file.get()));
+  } else if (flags.log_dir.isSome()) {
     Try<string> log = logging::getLogFile(
         logging::getLogSeverity(flags.logging_level));
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c624a97d/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index d1cf8a6..0395d00 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -371,6 +371,10 @@ Future<Response> Slave::Http::state(const Request& request)
     object.values["log_dir"] = slave->flags.log_dir.get();
   }
 
+  if (slave->flags.external_log_file.isSome()) {
+    object.values["external_log_file"] = slave->flags.external_log_file.get();
+  }
+
   JSON::Array frameworks;
   foreachvalue (Framework* framework, slave->frameworks) {
     frameworks.values.push_back(model(*framework));

http://git-wip-us.apache.org/repos/asf/mesos/blob/c624a97d/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index fca83b3..a8b2621 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -446,7 +446,15 @@ void Slave::initialize()
   route("/stats.json", None(), lambda::bind(&Http::stats, http, lambda::_1));
   route("/state.json", None(), lambda::bind(&Http::state, http, lambda::_1));
 
-  if (flags.log_dir.isSome()) {
+  // Expose the log file for the webui. Fall back to 'log_dir' if
+  // an explicit file was not specified.
+  if (flags.external_log_file.isSome()) {
+    files->attach(flags.external_log_file.get(), "/slave/log")
+      .onAny(defer(self(),
+                   &Self::fileAttached,
+                   lambda::_1,
+                   flags.external_log_file.get()));
+  } else if (flags.log_dir.isSome()) {
     Try<string> log = logging::getLogFile(
         logging::getLogSeverity(flags.logging_level));
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c624a97d/src/webui/master/static/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/controllers.js 
b/src/webui/master/static/js/controllers.js
index 41a70a8..7ee3d3d 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -334,10 +334,10 @@
 
   mesosApp.controller('HomeCtrl', function($dialog, $scope) {
     $scope.log = function($event) {
-      if (!$scope.state.log_dir) {
+      if (!$scope.state.external_log_file && !$scope.state.log_dir) {
         $dialog.messageBox(
           'Logging to a file is not enabled',
-          "Set the 'log_dir' option if you wish to access the logs.",
+          "Set the 'external_log_file' or 'log_dir' option if you wish to 
access the logs.",
           [{label: 'Continue'}]
         ).open();
       } else {
@@ -399,10 +399,10 @@
       var host = hostname + ":" + pid.substring(pid.lastIndexOf(':') + 1);
 
       $scope.log = function($event) {
-        if (!$scope.state.log_dir) {
+        if (!$scope.state.external_log_file && !$scope.state.log_dir) {
           $dialog.messageBox(
             'Logging to a file is not enabled',
-            "Set the 'log_dir' option if you wish to access the logs.",
+            "Set the 'external_log_file' or 'log_dir' option if you wish to 
access the logs.",
             [{label: 'Continue'}]
           ).open();
         } else {

Reply via email to