4coder/4ed_log.h

55 lines
941 B
C
Raw Normal View History

2017-06-12 21:35:06 +00:00
/*
* Mr. 4th Dimention - Allen Webster
*
* 12.06.2017
*
* Setup macro wrappers for the logging system.
*
*/
// TOP
#define GEN_LOG(l,m) l(m, sizeof(m)-1)
#define GEN_LOGF(l,...) do{ char space[4096]; \
i32 length = snprintf(space, sizeof(space), __VA_ARGS__); \
l(space, length); \
}while(0)
#if defined(IS_PLAT_LAYER)
# if defined(USE_LOG)
# define LOG(m) GEN_LOG(sysfunc.log, m)
2017-06-12 21:35:06 +00:00
# else
# define LOG(m)
# endif
# if defined(USE_LOGF)
# define LOGF(...) GEN_LOGF(sysfunc.log, __VA_ARGS__)
2017-06-12 21:35:06 +00:00
# else
# define LOGF(...)
# endif
2017-07-18 21:19:28 +00:00
#else /* Not platform layer */
2017-06-12 21:35:06 +00:00
# if defined(USE_LOG)
2017-07-18 21:19:28 +00:00
# define LOG(s,m) GEN_LOG((s)->log, m)
2017-06-12 21:35:06 +00:00
# else
2017-07-18 21:19:28 +00:00
# define LOG(s,m)
2017-06-12 21:35:06 +00:00
# endif
# if defined(USE_LOGF)
2017-07-18 21:19:28 +00:00
# define LOGF(s,...) GEN_LOGF((s)->log, __VA_ARGS__)
2017-06-12 21:35:06 +00:00
# else
2017-07-18 21:19:28 +00:00
# define LOGF(s,...)
2017-06-12 21:35:06 +00:00
# endif
#endif
2017-07-18 21:19:28 +00:00
// HACK(allen): Get rid of this dependency. Implement snprintf ourself or something.
#if defined(USE_LOG)
# include <stdio.h>
#endif
2017-06-12 21:35:06 +00:00
// BOTTOM