log: use flag for debug logs
This commit is contained in:
parent
9c138ddaca
commit
ec3de83413
@ -72,10 +72,10 @@ void init_cmd(void) {
|
||||
append_arg(supported_args, renderArg(i));
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("Undefined argument iterator %d", i);
|
||||
LOG_ERROR_EXIT("Undefined argument iterator %d", i);
|
||||
}
|
||||
}
|
||||
LOG_DEBUG("Cmd module initialised.")
|
||||
LOG_DEBUG("Cmd module initialised.");
|
||||
}
|
||||
|
||||
void exit_cmd(void) {
|
||||
@ -119,7 +119,7 @@ void free_arg_list(struct ArgList* list) {
|
||||
|
||||
struct CommandLineArg* parse_args(const int argc, char* argv[]) {
|
||||
if (argc < 2) {
|
||||
LOG_ERROR_USER("At least 1 argument required.");
|
||||
LOG_ERROR("At least 1 argument required.");
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FAILED_ALLOC_MESSAGE \
|
||||
LOG_ERROR("Allocation failed. Returned pointer is NULL.");
|
||||
LOG_ERROR_EXIT("Allocation failed. Returned pointer is NULL.");
|
||||
|
||||
#define cdo_malloc(size) ((void*)({ \
|
||||
void *__ptr__ = malloc(size); \
|
||||
|
||||
@ -90,21 +90,43 @@ static void create_log_line_simple(const char * _status,
|
||||
(cdo_log_enable_color) ? coloredLogLevels[SEVERITY] : plainLogLevels[SEVERITY] \
|
||||
)
|
||||
|
||||
#define LOG_INFO( fmt, ...) \
|
||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_INFO), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
|
||||
#define LOG_INFO(fmt, ...) do { \
|
||||
if (cdo_log_enable_debug) { \
|
||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_INFO), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \
|
||||
} else { \
|
||||
create_log_line_simple(GET_LOG_SEVERITY_STR(LEVEL_INFO), fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOG_WARNING(fmt, ...) \
|
||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_WARNING), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
|
||||
#define LOG_WARNING(fmt, ...) do { \
|
||||
if (cdo_log_enable_debug) { \
|
||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_WARNING), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \
|
||||
} else { \
|
||||
create_log_line_simple(GET_LOG_SEVERITY_STR(LEVEL_WARNING), fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOG_ERROR(fmt, ...) \
|
||||
#define LOG_ERROR(fmt, ...) do { \
|
||||
if (cdo_log_enable_debug) { \
|
||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_ERROR), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \
|
||||
exit(1);
|
||||
} else { \
|
||||
create_log_line_simple(GET_LOG_SEVERITY_STR(LEVEL_ERROR), fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOG_ERROR_USER(fmt, ...) \
|
||||
create_log_line_simple(GET_LOG_SEVERITY_STR(LEVEL_ERROR), fmt, ##__VA_ARGS__);
|
||||
#define LOG_ERROR_EXIT(fmt, ...) do { \
|
||||
LOG_ERROR(fmt, ##__VA_ARGS__); \
|
||||
exit(1); \
|
||||
} while (0)
|
||||
|
||||
#define LOG_DEBUG(fmt, ...) do { \
|
||||
if (cdo_log_enable_debug) { \
|
||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_DEBUG), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \
|
||||
} else { \
|
||||
create_log_line_simple(GET_LOG_SEVERITY_STR(LEVEL_DEBUG), fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOG_DEBUG(fmt, ...) \
|
||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_DEBUG), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user