1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef IOTJS_DEBUGLOG_H
17 #define IOTJS_DEBUGLOG_H
20 #ifdef ENABLE_DEBUG_LOG
24 extern int iotjs_debug_level;
25 extern FILE* iotjs_log_stream;
26 extern const char* iotjs_debug_prefix[4];
32 #define IOTJS_DLOG(lvl, ...) \
34 if (0 <= lvl && lvl <= iotjs_debug_level && iotjs_log_stream) { \
35 fprintf(iotjs_log_stream, "[%s] ", iotjs_debug_prefix[lvl]); \
36 fprintf(iotjs_log_stream, __VA_ARGS__); \
37 fprintf(iotjs_log_stream, "\n"); \
38 fflush(iotjs_log_stream); \
41 #define DLOG(...) IOTJS_DLOG(DBGLEV_ERR, __VA_ARGS__)
42 #define DDLOG(...) IOTJS_DLOG(DBGLEV_WARN, __VA_ARGS__)
43 #define DDDLOG(...) IOTJS_DLOG(DBGLEV_INFO, __VA_ARGS__)
46 Use DLOG for errors, default you will see them
47 Use DDLOG for warnings, set iotjs_debug_level=2 to see them
48 USE DDDLOG for information, set iotjs_debug_level=3 to see them
51 #else /* !ENABLE_DEBUG_LOG */
53 #define IOTJS_DLOG(...)
58 #endif /* ENABLE_DEBUG_LOG */
61 void init_debug_settings();
62 void release_debug_settings();
65 #endif /* IOTJS_DEBUGLOG_H */