replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / logger / include / trace.h
1 //******************************************************************
2 //
3 // Copyright 2017 Samsung Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef TRACE_H_
22 #define TRACE_H_
23
24 #ifdef __ANDROID__
25 #include "logger.h"
26 #elif defined(__TIZEN__)
27 #ifdef OIC_SUPPORT_TIZEN_TRACE
28 #include <ttrace.h>
29 #endif
30 #elif defined(ARDUINO)
31 #endif
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 #ifdef __ANDROID__
39
40 void oic_trace_begin(const char *name, ...);
41 void oic_trace_end();
42 void oic_trace_buffer(const char *name, const uint8_t * buffer, size_t bufferSize);
43
44 #define OIC_TRACE_BEGIN(MSG, ...)
45 #define OIC_TRACE_END()
46 #define OIC_TRACE_MARK(MSG, ...)
47 #define OIC_TRACE_BUFFER(MSG, BUF, SIZ)
48
49 #elif defined(__TIZEN__)
50 /* trace macro for Tizen. this will call ttrace api internally*/
51 #ifdef OIC_SUPPORT_TIZEN_TRACE
52
53 #include <ttrace.h>
54
55 void oic_trace_buffer(const char *name, const uint8_t * buffer, size_t bufferSize);
56
57 /* ttrace api is available on tizen2.4 (or above) only */
58 #define OIC_TRACE_BEGIN(MSG, ...) \
59         traceBegin(TTRACE_TAG_APP, "OIC:"#MSG, ##__VA_ARGS__)
60 #define OIC_TRACE_END() \
61         traceEnd(TTRACE_TAG_APP)
62 #define OIC_TRACE_MARK(MSG, ...) \
63         traceBegin(TTRACE_TAG_APP, "OIC:"#MSG, ##__VA_ARGS__), \
64         traceEnd(TTRACE_TAG_APP)
65 #define OIC_TRACE_BUFFER(MSG, BUF, SIZ) \
66         oic_trace_buffer(MSG, BUF, SIZ)
67 #else
68 #define OIC_TRACE_BEGIN(MSG, ...)
69 #define OIC_TRACE_END()
70 #define OIC_TRACE_MARK(MSG, ...)
71 #define OIC_TRACE_BUFFER(MSG, BUF, SIZ)
72 #endif
73
74 #elif defined(ARDUINO)
75 /* trace macro for Arduino. currently this will call nothing*/
76 #define OIC_TRACE_BEGIN(MSG, ...)
77 #define OIC_TRACE_END()
78 #define OIC_TRACE_MARK(MSG, ...)
79 #define OIC_TRACE_BUFFER(MSG, BUF, SIZ)
80
81 #else
82 #define OIC_TRACE_BEGIN(MSG, ...)
83 #define OIC_TRACE_END()
84 #define OIC_TRACE_MARK(MSG, ...)
85 #define OIC_TRACE_BUFFER(MSG, BUF, SIZ)
86
87 #endif //endif
88
89 #ifdef __cplusplus
90 }
91 #endif // __cplusplus
92
93 #endif /* TRACE_H_ */