From 6a3e4ee8616a1dbda6e180a7fea37a789e8a01f2 Mon Sep 17 00:00:00 2001 From: Arkadiusz Pietraszek Date: Tue, 15 Jan 2019 12:26:38 +0100 Subject: [PATCH] [Common][Utils] Adding functions to unify deprecation warnings. [Verification] Code compiles successfully. Change-Id: Id81aa801f3858ead071ef8899cb9cfc4136ad589 Signed-off-by: Arkadiusz Pietraszek --- src/common/tools.cc | 11 +++++++++++ src/common/tools.h | 2 ++ src/utils/utils_api.js | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/src/common/tools.cc b/src/common/tools.cc index fd4a2f3..9e0466c 100644 --- a/src/common/tools.cc +++ b/src/common/tools.cc @@ -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 diff --git a/src/common/tools.h b/src/common/tools.h index 88136c4..73acde6 100644 --- a/src/common/tools.h +++ b/src/common/tools.h @@ -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 diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js index 90f7a5c..5eb3f65 100644 --- a/src/utils/utils_api.js +++ b/src/utils/utils_api.js @@ -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 */ -- 2.7.4