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));
|
append_arg(supported_args, renderArg(i));
|
||||||
break;
|
break;
|
||||||
default:
|
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) {
|
void exit_cmd(void) {
|
||||||
@ -119,7 +119,7 @@ void free_arg_list(struct ArgList* list) {
|
|||||||
|
|
||||||
struct CommandLineArg* parse_args(const int argc, char* argv[]) {
|
struct CommandLineArg* parse_args(const int argc, char* argv[]) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
LOG_ERROR_USER("At least 1 argument required.");
|
LOG_ERROR("At least 1 argument required.");
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define FAILED_ALLOC_MESSAGE \
|
#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*)({ \
|
#define cdo_malloc(size) ((void*)({ \
|
||||||
void *__ptr__ = malloc(size); \
|
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] \
|
(cdo_log_enable_color) ? coloredLogLevels[SEVERITY] : plainLogLevels[SEVERITY] \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define LOG_INFO( fmt, ...) \
|
#define LOG_INFO(fmt, ...) do { \
|
||||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_INFO), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
|
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, ...) \
|
#define LOG_WARNING(fmt, ...) do { \
|
||||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_WARNING), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
|
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 { \
|
||||||
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_ERROR), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \
|
if (cdo_log_enable_debug) { \
|
||||||
exit(1);
|
create_log_line(GET_LOG_SEVERITY_STR(LEVEL_ERROR), __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \
|
||||||
|
} else { \
|
||||||
|
create_log_line_simple(GET_LOG_SEVERITY_STR(LEVEL_ERROR), fmt, ##__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define LOG_ERROR_USER(fmt, ...) \
|
#define LOG_ERROR_EXIT(fmt, ...) do { \
|
||||||
create_log_line_simple(GET_LOG_SEVERITY_STR(LEVEL_ERROR), fmt, ##__VA_ARGS__);
|
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