[Common][Utils] Adding functions to unify deprecation warnings. 00/197600/4
authorArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Tue, 15 Jan 2019 11:26:38 +0000 (12:26 +0100)
committerArkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
Wed, 16 Jan 2019 11:04:02 +0000 (12:04 +0100)
[Verification] Code compiles successfully.

Change-Id: Id81aa801f3858ead071ef8899cb9cfc4136ad589
Signed-off-by: Arkadiusz Pietraszek <a.pietraszek@partner.samsung.com>
src/common/tools.cc
src/common/tools.h
src/utils/utils_api.js

index fd4a2f3..9e0466c 100644 (file)
@@ -579,5 +579,16 @@ PlatformResult CheckFileAvailability(const std::string& path) {
   return CheckFileStatus(path);
 }
 
+void PrintDeprecationWarningFor(const char* className, const char* replacement) {
+  if (nullptr == replacement) {
+    LoggerW("DEPRECATION WARNING: %s is deprecated and using it is not recommended.",
+          className);
+  } else {
+    LoggerW("DEPRECATION WARNING: %s is deprecated and using it is not recommended. Try using %s instead",
+          className, replacement);
+  }
+
+}
+
 }  // namespace tools
 }  // namespace common
index 88136c4..73acde6 100644 (file)
@@ -117,6 +117,8 @@ PlatformResult CheckFileStatus(const std::string& path);
 
 PlatformResult CheckFileAvailability(const std::string& path);
 
+void PrintDeprecationWarningFor(const char* className, const char* replacement = nullptr);
+
 }  // namespace tools
 }  // namespace common
 
index 90f7a5c..5eb3f65 100644 (file)
@@ -293,6 +293,15 @@ Utils.prototype.checkProfile = function() {
   return native_.getResultObject(result);
 };
 
+Utils.prototype.printDeprecationWarningFor = function(name, replacement) {
+  if (_type.isUndefined(replacement)) {
+    this.warn('DEPRECATION WARNING: ' + name + ' is deprecated and using it is not recommended.');
+  } else {
+    this.warn('DEPRECATION WARNING: ' + name + ' is deprecated and using it is not recommended.'
+    + "Try using " + replacement + " instead.");
+  }
+};
+
 
 /////////////////////////////////////////////////////////////////////////////
 /** @constructor */