sync with master
[platform/framework/native/appfw.git] / inc / FBaseLog.h
index 33b7585..dce4a69 100644 (file)
@@ -448,6 +448,28 @@ extern "C" {
        else {;}
 
 /**
+* If the condition is @c false, it prints a message, sets the last result, evaluates a cleanup expression
+* and goes to label.
+*
+* @since 2.1
+*
+* @param[in]    condition              The condition that is expected to be true
+* @param[in]    expr                   Expressions that are evaluated before going to catchLabel
+* @param[in]    catchLabel             The label for goto operation
+* @param[in]    r                      The last result to set
+* @param[in]    ...                    The message to display
+* @hideinitializer
+*/
+#define TryCatchLabelResult(condition, expr, catchLabel, r, ...) \
+       if (!(condition)) { \
+               SetLastResult(r); \
+               AppLogException(__VA_ARGS__); \
+               expr; \
+               goto catchLabel;        \
+       } \
+       else {;}
+
+/**
  * If the condition is @c false, the message is printed and a value is returned.
  *
  * @since 2.0
@@ -532,6 +554,22 @@ extern "C" {
        } \
        else {;}
 
+/**
+* If the condition is @c false, the informative log message is printed and a value is returned.
+*
+* @since 2.1
+*
+* @param[in]    condition              The condition that is expected to be true
+* @param[in]    returnValue            The value to return when the condition is @c false
+* @param[in]    ...                    The message to display
+* @hideinitializer
+*/
+#define TryLogReturn(condition, returnValue, ...) \
+       if (!(condition)) { \
+               AppLog(__VA_ARGS__); \
+               return returnValue;     \
+       } \
+       else {;}
 
 // TryTag Macros
 
@@ -578,6 +616,29 @@ extern "C" {
        else {;}
 
 /**
+* If the condition is @c false, it prints a message with a tag, sets the last result, evaluates a cleanup expression
+* and goes to label.
+*
+* @since 2.1
+*
+* @param[in]    tag                    Used to identify the source of a log message
+* @param[in]    condition              The condition that is expected to be true
+* @param[in]    expr                   Expressions that are evaluated before going to catchLabel
+* @param[in]    catchLabel             The label for goto operation
+* @param[in]    r                      The last result to set
+* @param[in]    ...                    The message to display
+* @hideinitializer
+*/
+#define TryCatchLabelResultTag(tag, condition, expr, catchLabel, r, ...) \
+       if (!(condition)) { \
+               SetLastResult(r); \
+               AppLogExceptionTag(tag, __VA_ARGS__); \
+               expr; \
+               goto catchLabel;        \
+       } \
+       else {;}
+
+/**
  * If the condition is @c false, the message is printed with a tag and a value is returned.
  *
  * @since 2.0
@@ -667,6 +728,148 @@ extern "C" {
        } \
        else {;}
 
+/**
+* If the condition is @c false, the informative log message is printed with a tag and a value is returned.
+*
+* @since 2.1
+*
+* @param[in]    tag                    Used to identify the source of a log message
+* @param[in]    condition              The condition that is expected to be true
+* @param[in]    returnValue            The value to return when the condition is @c false
+* @param[in]    ...                    The message to display
+* @hideinitializer
+*/
+#define TryLogReturnTag(tag, condition, returnValue, ...) \
+       if (!(condition)) { \
+               AppLogTag(tag, __VA_ARGS__); \
+               return returnValue;     \
+       } \
+       else {;}
+
+/** @} */
+
+
+// Secure Macros
+/**
+ * @addtogroup  GroupMacros
+ *
+ * @{
+ */
+#if (defined(_APP_LOG) || defined(_OSP_DEBUG_) || defined(_DEBUG)) && defined(_SECURE_LOG)
+
+#define AppSecureLog(...)                      AppLogInternal(__PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+#define AppSecureLogException(...)             AppLogExceptionInternal(__PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+
+#define AppSecureLogTag(tag, ...)              AppLogTagInternal(tag, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+#define AppSecureLogExceptionTag(tag, ...)     AppLogExceptionTagInternal(tag, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
+
+#else
+/**
+* This macro is to protect informative log messages which needs to keep security.
+* It allows display of informative log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+*
+* @since 2.1
+*
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the AppSecureLog macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           AppSecureLog("User ID : 'JoneDoe'");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define AppSecureLog(...)
+
+/**
+* This macro is to protect exception log messages which needs to keep security.
+* It allows display of exception log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+*
+* @since 2.1
+*
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the AppSecureLogException macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           //...
+*           if (something_wrong)
+*           {
+*              AppSecureLogException("User ID : 'JoneDoe' mismatch.");
+*
+*              return false;
+*           }
+*   //...
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define AppSecureLogException(...)
+
+/**
+* This macro is to protect informative log messages which needs to keep security, with a tag.
+* It allows display of informative log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+*
+* @since 2.1
+*
+* @param[in]   tag                     The user defined tag
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the AppSecureLogTag macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           AppSecureLogTag("MyTag", "User ID : 'JoneDoe'");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define AppSecureLogTag(tag, ...)
+
+/**
+* This macro is to protect exception log messages which needs to keep security, with a tag.
+* It allows display of exception log messages if compiled with "_SECURE_LOG" definition.
+* Otherwise, it will be removed in the compile time.
+*
+* @since 2.1
+*
+* @param[in]   tag                     The user defined tag
+* @param[in]   ...                     The message to display
+*
+* The following example demonstrates how to use the AppSecureLogExceptionTag macro.
+*
+* @code
+*        bool
+*        MyEngine::Init(int value)
+*        {
+*           AppSecureLogExceptionTag("MyTag", "User ID : 'JoneDoe' mismatch.");
+*
+*           return true;
+*        }
+* @endcode
+* @hideinitializer
+*/
+#define AppSecureLogExceptionTag(tag, ...)
+
+#endif
 /** @} */
 
 _OSP_EXPORT_ void AppLogInternal(const char* pFunction, int lineNumber, const char* pFormat, ...);