You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/09/18 21:22:21 UTC
[3/7] mesos git commit: Updated `logging::initialize()` to make flags
optional.
Updated `logging::initialize()` to make flags optional.
This will be used to initialize logging in the main functions
that do not use `mesos::internal::logging::Flags`.
Review: https://reviews.apache.org/r/62018/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0cd254f0
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0cd254f0
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0cd254f0
Branch: refs/heads/master
Commit: 0cd254f0f9aea2d638da36fb50a41318e5ba1d16
Parents: 0b83432
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Mon Sep 18 20:44:05 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Mon Sep 18 23:21:47 2017 +0200
----------------------------------------------------------------------
src/logging/logging.cpp | 31 +++++++++++++++++++------------
src/logging/logging.hpp | 2 +-
2 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0cd254f0/src/logging/logging.cpp
----------------------------------------------------------------------
diff --git a/src/logging/logging.cpp b/src/logging/logging.cpp
index 70d66a5..7085ab9 100644
--- a/src/logging/logging.cpp
+++ b/src/logging/logging.cpp
@@ -48,6 +48,8 @@ using fLB::FLAGS_drop_log_memory;
using process::Once;
+using std::cerr;
+using std::endl;
using std::string;
// Captures the stack trace and exits when a pure virtual method is
@@ -121,7 +123,7 @@ google::LogSeverity getLogSeverity(const string& logging_level)
void initialize(
const string& _argv0,
- const Flags& flags,
+ const Option<Flags>& _flags,
bool installFailureSignalHandler)
{
static Once* initialized = new Once();
@@ -132,23 +134,30 @@ void initialize(
argv0 = _argv0;
+ // Use the default flags if not specified.
+ Flags flags;
+ if (_flags.isSome()) {
+ flags = _flags.get();
+
+ FLAGS_minloglevel = getLogSeverity(flags.logging_level);
+ FLAGS_logbufsecs = flags.logbufsecs;
+ }
+
if (flags.logging_level != "INFO" &&
flags.logging_level != "WARNING" &&
flags.logging_level != "ERROR") {
- EXIT(EXIT_FAILURE)
- << "'" << flags.logging_level
- << "' is not a valid logging level. Possible values for"
- << " 'logging_level' flag are: 'INFO', 'WARNING', 'ERROR'.";
+ cerr << "'" << flags.logging_level << "' is not a valid logging level."
+ << " Possible values for 'logging_level' flag are:"
+ << " 'INFO', 'WARNING', 'ERROR'." << endl;
+ exit(EXIT_FAILURE);
}
- FLAGS_minloglevel = getLogSeverity(flags.logging_level);
-
if (flags.log_dir.isSome()) {
Try<Nothing> mkdir = os::mkdir(flags.log_dir.get());
if (mkdir.isError()) {
- EXIT(EXIT_FAILURE)
- << "Could not initialize logging: Failed to create directory "
- << flags.log_dir.get() << ": " << mkdir.error();
+ cerr << "Could not initialize logging: Failed to create directory "
+ << flags.log_dir.get() << ": " << mkdir.error() << endl;
+ exit(EXIT_FAILURE);
}
FLAGS_log_dir = flags.log_dir.get();
// Do not log to stderr instead of log files.
@@ -172,8 +181,6 @@ void initialize(
FLAGS_stderrthreshold = FLAGS_minloglevel;
}
- FLAGS_logbufsecs = flags.logbufsecs;
-
#ifdef __linux__
// Do not drop in-memory buffers of log contents. When set to true, this flag
// can significantly slow down the master. The slow down is attributed to
http://git-wip-us.apache.org/repos/asf/mesos/blob/0cd254f0/src/logging/logging.hpp
----------------------------------------------------------------------
diff --git a/src/logging/logging.hpp b/src/logging/logging.hpp
index 0e448f2..9ce1b1d 100644
--- a/src/logging/logging.hpp
+++ b/src/logging/logging.hpp
@@ -29,7 +29,7 @@ namespace logging {
void initialize(
const std::string& argv0,
- const Flags& flags,
+ const Option<Flags>& _flags = None(),
bool installFailureSignalHandler = false);