Skip to content

Commit

Permalink
log: add LOG_VAR macro
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 8, 2024
1 parent d4d35cc commit afaf12a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libtrx/include/libtrx/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
#define LOG_ERROR(...) Log_Message(__FILE__, __LINE__, __func__, __VA_ARGS__)
#define LOG_DEBUG(...) Log_Message(__FILE__, __LINE__, __func__, __VA_ARGS__)

#define LOG_VAR(var) \
_Generic( \
(var), \
int: LOG_DEBUG(#var ": %d", var), \
int8_t: LOG_DEBUG(#var ": %d", var), \
int16_t: LOG_DEBUG(#var ": %d", var), \
uint8_t: LOG_DEBUG(#var ": %d", var), \
uint16_t: LOG_DEBUG(#var ": %d", var), \
uint32_t: LOG_DEBUG(#var ": %d", var), \
float: LOG_DEBUG(#var ": %f", var), \
double: LOG_DEBUG(#var ": %f", var), \
char *: LOG_DEBUG(#var ": %s", var), \
default: LOG_DEBUG(#var ": %p", var))

void Log_Init(const char *path);
void Log_Shutdown(void);
void Log_Message(
Expand Down

0 comments on commit afaf12a

Please sign in to comment.