Revise Tizen::Io doxygen
[platform/framework/native/appfw.git] / inc / FBaseSysLog.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FBaseSysLog.h
19  * @brief               This is the header file for the %Log macros.
20  *
21  * This header file defines the Log macros.
22  */
23
24 #ifndef _FBASE_SYS_LOG_H_
25 #define _FBASE_SYS_LOG_H_
26
27 #include <stdarg.h>
28 #include <FOspConfig.h>
29 #include <FBaseDataType.h>
30 #include <FIoRegistry.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif // __cplusplus
35
36 #ifndef likely
37 #define likely(x)    __builtin_expect(!!(x), 1)
38 #endif
39 #ifndef unlikely
40 #define unlikely(x)  __builtin_expect(!!(x), 0)
41 #endif
42
43 /** 
44  * @mainpage Tizen Platform API Reference
45  *
46  * The Tizen platform API Reference provides the description of APIs for the platform developers.
47  */
48
49 /**
50  * @defgroup GroupMacros Debugging Macros
51  *
52  * This page describes the Tizen debugging macros used by the Tizen modules.
53  * These debugging macros should use specific NIDs ( Namespace ID ) to distinguish each Tizen module.
54  *
55  * @since 2.0
56  */
57
58
59 /**
60  * @addtogroup  GroupMacros
61  *
62  * @{
63  */
64
65 /**
66  * This macro allows the display of informative log messages.
67  * This system log macro is for the platform modules.
68  *
69  * @since 2.0
70  *
71  * @param[in]   NID                     The Tizen namespace
72  * @param[in]   ...         The message to display
73  *
74  * The following example demonstrates how to use the %SysLog macro.
75  *
76  * @code
77  *      bool
78  *      MyEngine::Init(int value)
79  *      {
80  *         SysLog(NID, "Initialization successful.");
81  *
82  *         return true; 
83  *      }
84  * @endcode
85  * @hideinitializer
86  */
87 #define SysLog(NID, ...)               SysLogInternal(NID, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
88
89 /**
90  * This macro allows the display of exception log messages with a tag and sets the last result.
91  * This system log macro is for the platform modules.
92  *
93  * @since 2.0
94  *
95  * @param[in]   NID                     The Tizen namespace
96  * @param[in]   r                       The last result to set
97  * @param[in]   ...                     The message to display
98  *
99  * The following example demonstrates how to use the SysLogException macro.
100  *
101  * @code
102  *      bool
103  *      MyEngine::Init(int value)
104  *      {
105  *         //...
106  *         if (something_wrong)   // The Try family macros can be used instead.
107  *         {
108  *            SysLogException(NID,  E_INVALID_ARG, "An unexpected error has occurred.");
109  *
110  *            return false;
111  *         }
112  *   //...
113  *
114  *         return true;
115  *      }
116  * @endcode
117  * @hideinitializer
118  */
119 #define SysLogException(NID, r, ...)               SysLogExceptionInternal(NID, r, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
120
121 /**
122  * This macro allows the display of informative log messages with a tag.
123  * This system log macro is for the platform modules.
124  *
125  * @since 2.0
126  *
127  * @param[in]   NID                     The Tizen namespace
128  * @param[in]   tag                     The user defined tag
129  * @param[in]   ...         The message to display
130  *
131  * The following example demonstrates how to use the SysLogTag macro.
132  *
133  * @code
134  *      bool
135  *      MyEngine::Init(int value)
136  *      {
137  *         SysLogTag(NID, "MyTag", "Initialization successful.");
138  *
139  *         return true;
140  *      }
141  * @endcode
142  * @hideinitializer
143  */
144 #define SysLogTag(NID, tag, ...)       SysLogTagInternal(NID, tag, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
145
146 /**
147  * This macro allows the display of exception log messages with a tag and sets the last result.
148  * This system log macro is for the platform modules.
149  *
150  * @since 2.0
151  *
152  * @param[in]   NID                     The Tizen namespace
153  * @param[in]   tag                     The user defined tag
154  * @param[in]   r                       The last result to set
155  * @param[in]   ...         The message to display
156  *
157  * The following example demonstrates how to use the SysLogTagException macro.
158  *
159  * @code
160  *      bool
161  *      MyEngine::Init(int value)
162  *      {
163  *         SysLogExceptionTag(NID, "MyTag", E_INVALID_ARG, "Initialization successful.");
164  *
165  *         return true;
166  *      }
167  * @endcode
168  * @hideinitializer
169  */
170 #define SysLogExceptionTag(NID, tag, r, ...)       SysLogExceptionTagInternal(NID, tag, r, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
171
172
173
174 /**
175  * This macro allows the display of informative log messages with a tag, when the condition is @c false.
176  * This system log macro is for the platform modules.
177  *
178  * @since 2.0
179  *
180  * @param[in]   NID                     The Tizen namespace
181  * @param[in]   condition       The condition that is expected to be true
182  * @param[in]   ...                     The message to display
183  *
184  * The following example demonstrates how to use the SysTryLog macro.
185  *
186  * @code
187  *      void
188  *      MyEngine::Init(int value)
189  *      {
190  *         //...
191  *
192  *         SysTryLog(NID, condition, "An unexpected error has occurred.");
193  *
194  *         //...
195  *      }
196  * @endcode
197  * @hideinitializer
198  */
199 #define SysTryLog(NID, condition, ...) \
200         do \
201         { \
202                 if (unlikely(!(condition))) {   \
203                         SysLog(NID, __VA_ARGS__); \
204                 } \
205         } while (0);
206
207 /**
208  * This macro allows the display of informative log messages, when the condition is @c false.
209  * Executes statements and goes to the catch label.
210  * This system log macro is for the platform modules.
211  *
212  * @since 2.0
213  *
214  * @param[in]   NID                     The Tizen namespace
215  * @param[in]   condition       The condition that is expected to be true
216  * @param[in]   expr            Expressions that are evaluated before going to the CATCH label
217  * @param[in]   ...                     The message to display
218  *
219  * The following example demonstrates how to use the SysTryLogCatch macro.
220  *
221  * @code
222  *      bool
223  *      MyEngine::Init(int value)
224  *      {
225  *         //...
226  *
227  *         SysTryLogCatch(NID, condition, r=E_INVALID_ARG, "An unexpected error has occurred.");
228  *
229  *         //...
230  *         CATCH:
231  *                      return false;
232  *      }
233  * @endcode
234  * @hideinitializer
235  */
236 #define SysTryLogCatch(NID, condition, expr, ...)       \
237         do \
238         { \
239                 if (unlikely(!(condition))) { \
240                         SysLog(NID, __VA_ARGS__); \
241                         expr; \
242                         goto CATCH;     \
243                 } \
244         } while (0);
245
246 /**
247  * This macro allows the display of informative log messages and returns @c returnValue, when the condition is @c false.
248  * This system log macro is for the platform modules.
249  *
250  * @since 2.0
251  *
252  * @param[in]   NID                             The Tizen namespace
253  * @param[in]   condition               The condition that is expected to be true
254  * @param[in]   returnValue     The value to return when the condition is @c false
255  * @param[in]   ...                             The message to display
256  *
257  * The following example demonstrates how to use the SysTryLogReturn macro.
258  *
259  * @code
260  *      bool
261  *      MyEngine::Init(int value)
262  *      {
263  *         //...
264  *
265  *         SysTryLogReturn(NID, condition, false, "An unexpected error has occurred.");
266  *
267  *         //...
268  *         return true;
269  *      }
270  * @endcode
271  * @hideinitializer
272  */
273 #define SysTryLogReturn(NID, condition, returnValue, ...) \
274         do \
275         { \
276                 if (unlikely(!(condition))) { \
277                         SysLog(NID, __VA_ARGS__); \
278                         return returnValue;     \
279                 } \
280         } while (0);
281
282
283 /**
284  * This macro allows the display of exception log messages with a tag and sets the last result, when the condition is @c false.
285  * This system log macro is for the platform modules.
286  *
287  * @since 2.0
288  *
289  * @param[in]   NID                     The Tizen namespace
290  * @param[in]   condition       The condition that is expected to be true
291  * @param[in]   returnValue The value to return when the condition is @c false
292  * @param[in]   r                       The last result to set
293  * @param[in]   ...                     The message to display
294  *
295  * The following example demonstrates how to use the SysTryReturn macro.
296  *
297  * @code
298  *      bool
299  *      MyEngine::Init(int value)
300  *      {
301  *         //...
302  *
303  *         SysTryReturn(NID, condition, false,  E_INVALID_ARG, "An unexpected error has occurred.");
304  *
305  *         //...
306  *         return true;
307  *      }
308  * @endcode
309  * @hideinitializer
310  */
311 #define SysTryReturn(NID, condition, returnValue, r, ...) \
312         do \
313         { \
314                 if (unlikely(!(condition))) {   \
315                         SysLogException(NID, r, __VA_ARGS__); \
316                         return returnValue;     \
317                 } \
318         } while (0);
319
320 /**
321  * This macro allows the display of exception log messages with a tag and sets the last result, when the condition is @c false.
322  * This is a shorthand macro for SysTryReturn(NID, condition, r, r, "[" # r "] " ...).
323  * This system log macro is for the platform modules.
324  *
325  * @since 2.0
326  *
327  * @param[in]   NID                     The Tizen namespace
328  * @param[in]   condition       The condition that is expected to be true
329  * @param[in]   r                       The last result to set
330  * @param[in]   ...                     The message to display
331  *
332  * The following example demonstrates how to use the SysTryReturnResult macro.
333  *
334  * @code
335  * #define E_UNKNOWN_ERROR 1
336  *      result
337  *      MyEngine::Init(int value)
338  *      {
339  *         //...
340  *
341  *         SysTryReturnResult(NID, condition, E_UNKNOWN_ERROR, "An unexpected error has occurred.");
342  *
343  *         //...
344  *         return E_SUCCESS;
345  *      }
346  * @endcode
347  * @hideinitializer
348  */
349 #define SysTryReturnResult(NID, condition, r, ...) \
350         do \
351         { \
352                 if (unlikely(!(condition))) {   \
353                         SysTryReturnResultInternal(NID, r, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__); \
354                         return r;       \
355                 } \
356         } while (0);
357
358 /**
359  * This macro allows the display of exception log messages with a tag and sets the last result, when the condition is @c false.
360  * This system log macro is for the platform modules.
361  *
362  * @since 2.0
363  *
364  * @param[in]   NID                     The Tizen namespace
365  * @param[in]   condition       The condition that is expected to be true
366  * @param[in]   r                       The last result to set
367  * @param[in]   ...                     The message to display
368  *
369  * The following example demonstrates how to use the SysTryReturnVoidResult macro.
370  *
371  * @code
372  *      void
373  *      MyEngine::Init(int value)
374  *      {
375  *         //...
376  *
377  *         SysTryReturnVoidResult(NID, condition,  E_INVALID_ARG, "An unexpected error has occurred.");
378  *
379  *         //...
380  *         return;
381  *      }
382  * @endcode
383  * @hideinitializer
384  */
385 #define SysTryReturnVoidResult(NID, condition, r, ...)  \
386         do \
387         { \
388                 if (unlikely(!(condition))) {   \
389                         SysLogException(NID, r, __VA_ARGS__); \
390                         return; \
391                 } \
392         } while (0);
393
394 /**
395  * This macro allows the display of exception log messages with a tag, when the condition is @c false.
396  * Executes statements, sets the last result and goes to the catch label.
397  * This system log macro is for the platform modules.
398  *
399  * @since 2.0
400  *
401  * @param[in]   NID                     The Tizen namespace
402  * @param[in]   condition       The condition that is expected to be true
403  * @param[in]   expr            Expressions that are evaluated before going to the CATCH label
404  * @param[in]   r                       The last result to set
405  * @param[in]   ...                     The message to display
406  *
407  * The following example demonstrates how to use the SysTryCatch macro.
408  *
409  * @code
410  *      bool
411  *      MyEngine::Init(int value)
412  *      {
413  *         //...
414  *
415  *         SysTryCatch(NID, condition, r=E_INVALID_ARG, E_INVALID_ARG, "An unexpected error has occurred.");
416  *
417  *         //...
418  *         CATCH:
419  *                      return false;
420  *      }
421  * @endcode
422  * @hideinitializer
423  */
424 #define SysTryCatch(NID, condition, expr, r, ...) \
425         do \
426         { \
427                 if (unlikely(!(condition))) {   \
428                         SysLogException(NID, r, __VA_ARGS__); \
429                         expr; \
430                         goto CATCH;     \
431                 } \
432         } while (0);
433
434 /**
435  * This macro allows the display of exception log messages with a tag, when the condition is @c false.
436  * Executes statements, sets the last result and goes to the catch label.
437  * This system log macro is for the platform modules.
438  *
439  * @since 2.0
440  *
441  * @param[in]   NID                     The Tizen namespace
442  * @param[in]   condition       The condition that is expected to be true
443  * @param[in]   expr            Expressions that are evaluated before going to the CATCH label
444  * @param[in]   catchLabel      The label for the goto operation
445  * @param[in]   r                       The last result to set
446  * @param[in]   ...                     The message to display
447  *
448  * The following example demonstrates how to use the SysTryCatchLabel macro.
449  *
450  * @code
451  *      bool
452  *      MyEngine::Init(int value)
453  *      {
454  *         //...
455  *
456  *         SysTryCatchLabel(NID, condition, r=E_INVALID_ARG, LABEL, E_INVALID_ARG, "An unexpected error has occurred.");
457  *
458  *         //...
459  *         LABEL:
460  *                      return false;
461  *      }
462  * @endcode
463  * @hideinitializer
464  */
465 #define SysTryCatchLabel(NID, condition, expr, catchLabel, r, ...) \
466         do \
467         { \
468                 if (unlikely(!(condition))) {   \
469                         SysLogException(NID, r, __VA_ARGS__); \
470                         expr; \
471                         goto catchLabel; \
472                 } \
473         } while (0);
474
475
476 /**
477  * This macro allows the display of exception log messages and the program expires, when the condition is @c false.
478  * This system log macro is for the platform modules.
479  *
480  * @since 2.0
481  *
482  * @param[in]   condition               The condition that is expected to be true
483  *
484  * The following example demonstrates how to use the SysAssert macro.
485  *
486  * @code
487  *      bool
488  *      MyEngine::Init(int value)
489  *      {
490  *         //...
491  *
492  *         SysAssert(condition);
493  *
494  *         //...
495  *      }
496  * @endcode
497  * @hideinitializer
498  */
499 #define SysAssert(condition) \
500         do \
501         { \
502                 if (unlikely(!(condition))) { \
503                         SysAssertInternal(__FILE__, __LINE__, __PRETTY_FUNCTION__);     \
504                 } \
505         } while (0);
506
507 /**
508  * This macro allows the display of exception log messages with a tag and the program expires, when the condition is @c false.
509  * This system log macro is for the platform modules.
510  *
511  * @since 2.0
512  *
513  * @param[in]   condition       The condition that is expected to be true
514  * @param[in]   ...                     The message to display
515  *
516  * The following example demonstrates how to use the SysAssertf macro.
517  *
518  * @code
519  *      bool
520  *      MyEngine::Init(int value)
521  *      {
522  *         //...
523  *
524  *         SysAssertf(condition, "");
525  *
526  *         //...
527  *      }
528  * @endcode
529  * @hideinitializer
530  */
531 #define SysAssertf(condition, ...) \
532         do \
533         { \
534                 if (unlikely(!(condition))) { \
535                         SysAssertfInternal(# condition, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__); \
536                 } \
537         } while (0);
538
539
540 /**
541  * This macro generates an error message during the compile time, when the condition is @c false.
542  * This system log macro is for the platform modules.
543  *
544  * @since 2.0
545  *
546  * @param[in]   condition               The condition that is expected to be true
547  *
548  * The following example demonstrates how to use the SysStaticAssert macro.
549  *
550  * @code
551  *      bool
552  *      MyEngine::Init(int value)
553  *      {
554  *         //...
555  *
556  *         SysStaticAssert(condition);
557  *
558  *         //...
559  *      }
560  * @endcode
561  * @hideinitializer
562  */
563 #define SysStaticAssert(condition) switch (0) { \
564 case 0: \
565 case condition: \
566   ; \
567 }
568
569
570 /**
571  * This macro allows the display of exception log messages.
572  * This system log macro is for the platform modules.
573  *
574  * @since 2.0
575  *
576  * @param[in]   NID                     The Tizen namespace
577  * @param[in]   r                       The last result to set
578  *
579  * The following example demonstrates how to use the SysPropagate macro.
580  *
581  * @code
582  *      bool
583  *      MyEngine::Init(int value)
584  *      {
585  *         //...
586  *
587  *         SysPropagate(NID, E_INVALID_ARG);
588  *
589  *         //...
590  *      }
591  * @endcode
592  * @hideinitializer
593  */
594 #define SysPropagate(NID, r)        SysPropagateInternal(__PRETTY_FUNCTION__, __LINE__, NID, r)
595
596 // Secure Macros
597 #if defined(_SECURE_LOG)
598
599 #define SysSecureLog(NID, ...)                          SysLogInternal(NID, __PRETTY_FUNCTION__, __LINE__, "[SECURE_LOG] "__VA_ARGS__)
600 #define SysSecureLogException(NID, r,...)               SysLogExceptionInternal(NID, r, __PRETTY_FUNCTION__, __LINE__, "[SECURE_LOG] "__VA_ARGS__)
601
602 #define SysSecureLogTag(NID, tag, ...)                  SysLogTagInternal(NID, tag, __PRETTY_FUNCTION__, __LINE__, "[SECURE_LOG] "__VA_ARGS__)
603 #define SysSecureLogExceptionTag(NID, tag, r, ...)      SysLogExceptionTagInternal(NID, tag, r, __PRETTY_FUNCTION__, __LINE__, "[SECURE_LOG] "__VA_ARGS__)
604
605 #else
606
607 /**
608  * This macro is used to protect informative log messages which need security.
609  * It allows the display of informative log messages if compiled with the "_SECURE_LOG" definition.
610  * Otherwise, it is removed in the compile time.
611  * This system log macro is for the platform modules.
612  *
613  * @since 2.1
614  *
615  * @param[in]   NID                     The Tizen namespace ID
616  * @param[in]   ...                     The message to display
617  *
618  * The following example demonstrates how to use the SysSecureLog macro.
619  *
620  * @code
621  *        bool
622  *        MyEngine::Init(int value)
623  *        {
624  *           SysSecureLog(NID, "User ID : 'JoneDoe'");
625  *
626  *           return true;
627  *        }
628  * @endcode
629  * @hideinitializer
630  */
631 #define SysSecureLog(NID, ...)
632
633 /**
634  * This macro is used to protect exception log messages which needs security, and sets the last result.
635  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
636  * Otherwise, the log printing functionality is removed in the compile time.
637  * This system log macro is for the platform modules.
638  *
639  * @since 2.1
640  *
641  * @param[in]   NID                     The Tizen namespace ID
642  * @param[in]   r                       The last result to set
643  * @param[in]   ...                     The message to display
644  *
645  * The following example demonstrates how to use the SysSecureLogException macro.
646  *
647  * @code
648  *        bool
649  *        MyEngine::Init(int value)
650  *        {
651  *           //...
652  *           if (something_wrong)
653  *           {
654  *              SysSecureLogException(NID,  E_INVALID_ARG, "User ID : 'JoneDoe' mismatch.");
655  *
656  *              return false;
657  *           }
658  *   //...
659  *
660  *           return true;
661  *        }
662  * @endcode
663  * @hideinitializer
664  */
665 #define SysSecureLogException(NID, r,...)                       SetLastResult(r);
666
667 /**
668  * This macro is used to protect informative log messages which need security, with a tag.
669  * It allows the display of informative log messages if compiled with the "_SECURE_LOG" definition.
670  * Otherwise, it is removed in the compile time.
671  * This system log macro is for the platform modules.
672  *
673  * @since 2.1
674  *
675  * @param[in]   NID                     The Tizen namespace ID
676  * @param[in]   tag                     The user defined tag
677  * @param[in]   ...                     The message to display
678  *
679  * The following example demonstrates how to use the SysSecureLogTag macro.
680  *
681  * @code
682  *        bool
683  *        MyEngine::Init(int value)
684  *        {
685  *           SysSecureLogTag(NID, "MyTag", "User ID : 'JoneDoe'");
686  *
687  *           return true;
688  *        }
689  * @endcode
690  * @hideinitializer
691  */
692 #define SysSecureLogTag(NID, tag, ...)
693
694 /**
695  * This macro is used to protect exception log messages which need security, with a tag and sets the last result.
696  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
697  * Otherwise, the log printing functionality is removed in the compile time.
698  * This system log macro is for the platform modules.
699  *
700  * @since 2.1
701  *
702  * @param[in]   NID                     The Tizen namespace ID
703  * @param[in]   tag                     The user defined tag
704  * @param[in]   r                       The last result to set
705  * @param[in]   ...                     The message to display
706  *
707  * The following example demonstrates how to use the SysSecureLogExceptionTag macro.
708  *
709  * @code
710  *        bool
711  *        MyEngine::Init(int value)
712  *        {
713  *           SysSecureLogExceptionTag(NID, "MyTag", E_INVALID_ARG, "User ID : 'JoneDoe' mismatch.");
714  *
715  *           return true;
716  *        }
717  * @endcode
718  * @hideinitializer
719  */
720 #define SysSecureLogExceptionTag(NID, tag, r, ...)              SetLastResult(r);
721
722 #endif
723
724 /**
725  * This macro allows the display of informative log messages with a tag, when the condition is @c false.
726  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
727  * Otherwise, the log printing functionality is removed in the compile time.
728  * This system log macro is for the platform modules.
729  *
730  * @since 2.1
731  *
732  * @param[in]   NID                     The Tizen namespace
733  * @param[in]   condition       The condition that is expected to be true
734  * @param[in]   ...                     The message to display
735  *
736  * The following example demonstrates how to use the SysSecureTry macro.
737  *
738  * @code
739  *      bool
740  *      MyEngine::Init(int value)
741  *      {
742  *         //...
743  *
744  *         SysSecureTryLog(NID, condition, "Password mismatch : %s", password );
745  *
746  *         //...
747  *      }
748  * @endcode
749  * @hideinitializer
750  */
751 #define SysSecureTryLog(NID, condition, ...) \
752         do \
753         { \
754                 if (unlikely(!(condition))) {   \
755                         SysSecureLog(NID, __VA_ARGS__); \
756                 } \
757         } while (0);
758
759 /**
760  * This macro allows the display of informative log messages, when the condition is @c false.
761  * Executes statements and goes to the catch label.
762  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
763  * Otherwise, the log printing functionality is removed in the compile time.
764  * This system log macro is for the platform modules.
765  *
766  * @since 2.1
767  *
768  * @param[in]   NID                     The Tizen namespace
769  * @param[in]   condition       The condition that is expected to be true
770  * @param[in]   expr            Expressions that are evaluated before going to the CATCH label
771  * @param[in]   ...                     The message to display
772  * @hideinitializer
773  */
774 #define SysSecureTryLogCatch(NID, condition, expr, ...) \
775         do \
776         { \
777                 if (unlikely(!(condition))) { \
778                         SysSecureLog(NID, __VA_ARGS__); \
779                         expr; \
780                         goto CATCH;     \
781                 } \
782         } while (0);
783
784 /**
785  * This macro allows the display of informative log messages and returns @c returnValue, when the condition is @c false.
786  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
787  * Otherwise, the log printing functionality is removed in the compile time.
788  * This system log macro is for the platform modules.
789  *
790  * @since 2.1
791  *
792  * @param[in]   NID                     The Tizen namespace
793  * @param[in]   condition       The condition that is expected to be true
794  * @param[in]   returnValue The value to return when the condition is @c false
795  * @param[in]   ...                     The message to display
796  * @hideinitializer
797  */
798 #define SysSecureTryLogReturn(NID, condition, returnValue, ...) \
799         do \
800         { \
801                 if (unlikely(!(condition))) { \
802                         SysSecureLog(NID, __VA_ARGS__); \
803                         return returnValue;     \
804                 } \
805         } while (0);
806
807 /**
808  * This macro allows the display of exception log messages with a tag and sets the last result, when the condition is @c false.
809  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
810  * Otherwise, the log printing functionality is removed in the compile time.
811  * This system log macro is for the platform modules.
812  *
813  * @since 2.1
814  *
815  * @param[in]   NID                     The Tizen namespace
816  * @param[in]   condition       The condition that is expected to be true
817  * @param[in]   returnValue The value to return when the condition is @c false
818  * @param[in]   r                       The last result to set
819  * @param[in]   ...                     The message to display
820  * @hideinitializer
821  */
822 #define SysSecureTryReturn(NID, condition, returnValue, r, ...) \
823         do \
824         { \
825                 if (unlikely(!(condition))) {   \
826                         SysSecureLogException(NID, r, __VA_ARGS__); \
827                         return returnValue;     \
828                 } \
829         } while (0);
830
831 #if defined(_SECURE_LOG)
832 /**
833  * This macro allows the display of exception log messages with a tag and sets the last result, when the condition is @c false.
834  * This is a shorthand macro for SysSecureTryReturn(NID, condition, r, r, "[" # r "] " ...).
835  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
836  * Otherwise, the log printing functionality is removed in the compile time.
837  * This system log macro is for the platform modules.
838  *
839  * @since 2.1
840  *
841  * @param[in]   NID                     The Tizen namespace
842  * @param[in]   condition       The condition that is expected to be true
843  * @param[in]   r                       The last result to set
844  * @param[in]   ...                     The message to display
845  * @hideinitializer
846  */
847 #define SysSecureTryReturnResult(NID, condition, r, ...) \
848         do \
849         { \
850                 if (unlikely(!(condition))) {   \
851                         SysTryReturnResultInternal(NID, r, __PRETTY_FUNCTION__, __LINE__, "[SECURE_LOG] "__VA_ARGS__); \
852                         return r;       \
853                 } \
854         } while (0);
855
856 #else
857 #define SysSecureTryReturnResult(NID, condition, r, ...) \
858         do \
859         { \
860                 if (unlikely(!(condition))) {   \
861                         SetLastResult(r); \
862                         return r;       \
863                 } \
864         } while (0);
865 #endif
866
867 /**
868  * This macro allows the display of exception log messages with a tag and sets the last result, when the condition is @c false.
869  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
870  * Otherwise, the log printing functionality is removed in the compile time.
871  * This system log macro is for the platform modules.
872  *
873  * @since 2.1
874  *
875  * @param[in]   NID                     The Tizen namespace
876  * @param[in]   condition       The condition that is expected to be true
877  * @param[in]   r                       The last result to set
878  * @param[in]   ...                     The message to display
879  * @hideinitializer
880  */
881 #define SysSecureTryReturnVoidResult(NID, condition, r, ...)    \
882         do \
883         { \
884                 if (unlikely(!(condition))) {   \
885                         SysSecureLogException(NID, r, __VA_ARGS__); \
886                         return; \
887                 } \
888         } while (0);
889
890 /**
891  * This macro allows the display of exception log messages with a tag, when the condition is @c false.
892  * Executes statements, sets the last result and goes to the catch label.
893  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
894  * Otherwise, the log printing functionality is removed in the compile time.
895  * This system log macro is for the platform modules.
896  *
897  * @since 2.1
898  *
899  * @param[in]   NID                     The Tizen namespace
900  * @param[in]   condition       The condition that is expected to be true
901  * @param[in]   expr            Expressions that are evaluated before going to the CATCH label
902  * @param[in]   r                       The last result to set
903  * @param[in]   ...                     The message to display
904  * @hideinitializer
905  */
906 #define SysSecureTryCatch(NID, condition, expr, r, ...) \
907         do \
908         { \
909                 if (unlikely(!(condition))) {   \
910                         SysSecureLogException(NID, r, __VA_ARGS__); \
911                         expr; \
912                         goto CATCH;     \
913                 } \
914         } while (0);
915
916 /**
917  * This macro allows the display of exception log messages with a tag, when the condition is @c false.
918  * Executes statements, sets the last result and goes to the catch label.
919  * It allows the display of exception log messages if compiled with the "_SECURE_LOG" definition.
920  * Otherwise, the log printing functionality is removed in the compile time.
921  * This system log macro is for the platform modules.
922  *
923  * @since 2.1
924  *
925  * @param[in]   NID                     The Tizen namespace
926  * @param[in]   condition       The condition that is expected to be true
927  * @param[in]   expr            Expressions that are evaluated before going to the CATCH label
928  * @param[in]   catchLabel      The label for the goto operation
929  * @param[in]   r                       The last result to set
930  * @param[in]   ...                     The message to display
931  * @hideinitializer
932  */
933 #define SysSecureTryCatchLabel(NID, condition, expr, catchLabel, r, ...) \
934         do \
935         { \
936                 if (unlikely(!(condition))) {   \
937                         SysSecureLogException(NID, r, __VA_ARGS__); \
938                         expr; \
939                         goto catchLabel; \
940                 } \
941         } while (0);
942
943
944 /**
945  * Defines the log ID.
946  */
947 enum LogID
948 {
949 //Tizen Namespace ID ===============================================================
950         NID_APP = 0,
951
952         NID_BASE = 10,
953         NID_BASE_COL = 11,
954         NID_BASE_RT = 12,
955         NID_BASE_UTIL = 13,
956
957         NID_CNT = 20,
958
959         NID_CTXT = 30,
960
961         NID_GRP = 40,
962
963         NID_IO = 50,
964
965         NID_LCL = 60,
966
967         NID_LOC = 70,
968         NID_LOC_CTRL = 71,
969         NID_LOC_SVC = 72,
970
971         NID_MEDIA = 80,
972
973         NID_MSG = 90,
974
975         NID_NET = 100,
976         NID_NET_BT = 101,
977         NID_NET_HTTP = 102,
978         NID_NET_NFC = 103,
979         NID_NET_SOCK = 104,
980         NID_NET_WIFI = 105,
981
982         NID_SEC = 110,
983         NID_SEC_CERT = 111,
984         NID_SEC_CRYPTO = 112,
985
986         NID_SCL = 120,
987
988         NID_SYS = 130,
989
990         NID_TEL = 140,
991
992         NID_TEXT = 150,
993
994         NID_UI = 160,
995         NID_UI_ANIM = 161,
996         NID_UI_CTRL = 162,
997         NID_UI_EFFECT = 163,
998         NID_UI_IME = 164,
999         NID_UI_SCENES = 165,
1000
1001         NID_UIX = 170,
1002         NID_UIX_SPEECH = 171,
1003
1004         NID_WEB = 180,
1005         NID_WEB_CTRL = 181,
1006         NID_WEB_JSON = 182,
1007
1008         NID_SHELL = 190
1009 };
1010
1011 /**
1012 *
1013 @} */
1014
1015 _OSP_EXPORT_ void SysLogInternal(unsigned long id, const char* pFunction, int lineNumber, const char* pFormat, ...);
1016 _OSP_EXPORT_ void SysLogExceptionInternal(unsigned long id, result r, const char* pFunction, int lineNumber, const char* pFormat, ...);
1017
1018 _OSP_EXPORT_ void SysLogTagInternal(unsigned long id, const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...);
1019 _OSP_EXPORT_ void SysLogExceptionTagInternal(unsigned long id, const char* pTag, result r, const char* pFunction, int lineNumber, const char* pFormat, ...);
1020
1021 _OSP_EXPORT_ void SysAssertInternal(const char* pFileName, int lineNumber, const char* pFunction);
1022 _OSP_EXPORT_ void SysAssertfInternal(const char* expr, const char* pFunction, int lineNumber, const char* pFormat, ...);
1023
1024 _OSP_EXPORT_ void SysPropagateInternal(const char* pFunction, int lineNumber, unsigned long nid, result r);
1025
1026 _OSP_EXPORT_ void SysTryReturnResultInternal(unsigned long id, result r, const char* pFunction, int lineNumber, const char* pFormat, ...);
1027
1028 #ifdef __cplusplus
1029 }
1030 #endif // __cplusplus
1031
1032
1033 #endif // _FBASE_SYS_LOG_H_