]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: capture check_experimental_feature_enabled message
authorLoic Dachary <ldachary@redhat.com>
Thu, 12 Feb 2015 14:34:40 +0000 (15:34 +0100)
committerLoic Dachary <ldachary@redhat.com>
Fri, 13 Feb 2015 16:09:33 +0000 (17:09 +0100)
Implement check_experimental_feature_enabled so that it returns the
message instead of unconditionally displaying it via derr. It allows the
caller to display it in another context.

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/common/ceph_context.cc
src/common/ceph_context.h

index 7f1adb091f4d58a5ecde3cd177194c385d898275..79aff8b8cf181a144d54497776ae130a6f6ebac4 100644 (file)
@@ -182,27 +182,36 @@ public:
   }
 };
 
-bool CephContext::check_experimental_feature_enabled(std::string feat)
+bool CephContext::check_experimental_feature_enabled(const std::string& feat)
+{
+  stringstream message;
+  bool enabled = check_experimental_feature_enabled(feat, &message);
+  lderr(this) << message.str() << dendl;
+  return enabled;
+}
+
+bool CephContext::check_experimental_feature_enabled(const std::string& feat,
+                                                    std::ostream *message)
 {
   ceph_spin_lock(&_feature_lock);
   bool enabled = _experimental_features.count(feat);
   ceph_spin_unlock(&_feature_lock);
 
   if (enabled) {
-    lderr(this) << "WARNING: experimental feature '" << feat << "' is enabled" << dendl;
-    lderr(this) << "Please be aware that this feature is experimental, untested," << dendl;
-    lderr(this) << "unsupported, and may result in data corruption, data loss," << dendl;
-    lderr(this) << "and/or irreparable damage to your cluster.  Do not use" << dendl;
-    lderr(this) << "feature with important data." << dendl;
+    (*message) << "WARNING: experimental feature '" << feat << "' is enabled\n";
+    (*message) << "Please be aware that this feature is experimental, untested,\n";
+    (*message) << "unsupported, and may result in data corruption, data loss,\n";
+    (*message) << "and/or irreparable damage to your cluster.  Do not use\n";
+    (*message) << "feature with important data.\n";
   } else {
-    lderr(this) << "*** experimental feature '" << feat << "' is not enabled ***" << dendl;
-    lderr(this) << "This feature is marked as experimental, which means it" << dendl;
-    lderr(this) << " - is untested" << dendl;
-    lderr(this) << " - is unsupported" << dendl;
-    lderr(this) << " - may corrupt your data" << dendl;
-    lderr(this) << " - may break your cluster is an unrecoverable fashion" << dendl;
-    lderr(this) << "To enable this feature, add this to your ceph.conf:" << dendl;
-    lderr(this) << "  enable experimental unrecoverable data corrupting features = " << feat << dendl;
+    (*message) << "*** experimental feature '" << feat << "' is not enabled ***\n";
+    (*message) << "This feature is marked as experimental, which means it\n";
+    (*message) << " - is untested\n";
+    (*message) << " - is unsupported\n";
+    (*message) << " - may corrupt your data\n";
+    (*message) << " - may break your cluster is an unrecoverable fashion\n";
+    (*message) << "To enable this feature, add this to your ceph.conf:\n";
+    (*message) << "  enable experimental unrecoverable data corrupting features = " << feat << "\n";
   }
   return enabled;
 }
index c332bdfa70bc34418f564530581a68366194cc6c..a8dfec55410e75805db9510136b870ae6aa1acb4 100644 (file)
@@ -126,7 +126,9 @@ public:
   CryptoHandler *get_crypto_handler(int type);
 
   /// check if experimental feature is enable, and emit appropriate warnings
-  bool check_experimental_feature_enabled(std::string feature);
+  bool check_experimental_feature_enabled(const std::string& feature);
+  bool check_experimental_feature_enabled(const std::string& feature,
+                                         std::ostream *message);
 
 private:
   CephContext(const CephContext &rhs);