Module refactoring

This commit is contained in:
Peter
2019-06-16 00:51:10 +01:00
parent 819583121e
commit 08fe209b9f
1118 changed files with 9144 additions and 9141 deletions

View File

@@ -0,0 +1,27 @@
#include "platform_log.h"
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#define LOG_VPRINTF(priority) printf("(" priority ") %s: ", tag); \
va_list arg_ptr; \
va_start(arg_ptr, fmt); \
vprintf(fmt, arg_ptr); \
va_end(arg_ptr); \
printf("\n");
void _debug_log_v(const char *tag, const char *fmt, ...) {
LOG_VPRINTF("VERBOSE");
}
void _debug_log_d(const char *tag, const char *fmt, ...) {
LOG_VPRINTF("DEBUG");
}
void _debug_log_w(const char *tag, const char *fmt, ...) {
LOG_VPRINTF("WARN");
}
void _debug_log_e(const char *tag, const char *fmt, ...) {
LOG_VPRINTF("ERROR");
}

View File

@@ -0,0 +1,22 @@
#include "platform_macros.h"
#ifndef LOGGING_ON
#define LOGGING_ON 0
#endif
void _debug_log_v(const char* tag, const char* text, ...) PRINTF_ATTRIBUTE(2, 3);
void _debug_log_d(const char* tag, const char* text, ...) PRINTF_ATTRIBUTE(2, 3);
void _debug_log_w(const char* tag, const char* text, ...) PRINTF_ATTRIBUTE(2, 3);
void _debug_log_e(const char* tag, const char* text, ...) PRINTF_ATTRIBUTE(2, 3);
#define DEBUG_LOG_PRINT_V(tag, fmt, ...) do { if (LOGGING_ON) _debug_log_v(tag, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0)
#define DEBUG_LOG_PRINT_D(tag, fmt, ...) do { if (LOGGING_ON) _debug_log_d(tag, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0)
#define DEBUG_LOG_PRINT_W(tag, fmt, ...) do { if (LOGGING_ON) _debug_log_w(tag, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0)
#define DEBUG_LOG_PRINT_E(tag, fmt, ...) do { if (LOGGING_ON) _debug_log_e(tag, "%s:%d:%s(): " fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0)
#define DEBUG_LOG_WRITE_V(tag, text) DEBUG_LOG_PRINT_V(tag, "%s", text)
#define DEBUG_LOG_WRITE_D(tag, text) DEBUG_LOG_PRINT_D(tag, "%s", text)
#define DEBUG_LOG_WRITE_W(tag, text) DEBUG_LOG_PRINT_W(tag, "%s", text)
#define DEBUG_LOG_WRITE_E(tag, text) DEBUG_LOG_PRINT_E(tag, "%s", text)
#define CRASH(e) DEBUG_LOG_WRITE_E("Assert", #e); __builtin_trap()

View File

@@ -0,0 +1,5 @@
#if defined(__GNUC__)
#define PRINTF_ATTRIBUTE(format_pos, arg_pos) __attribute__((format(printf, format_pos, arg_pos)))
#else
#define PRINTF_ATTRIBUTE(format_pos, arg_pos)
#endif