// would be nice if __FUNC__ could be concatenated at compile time
#if 0
// less work, bigger binary
- #define __SOURCELOC__ (sprintf("^7%s^9(^9"__FILE__"^7:^9"STR(__LINE__)"^7)", __FUNC__))
+ #define __SOURCELOC__ (sprintf("^7%s^9(^9"__FILE__"^7:^9"STR(__LINE__)"^7)\n", __FUNC__))
#else
- #define __SOURCELOC__ (sprintf("^7%s^9(^9%s^7:^9%s^7)", __FUNC__, __FILE__, STR(__LINE__)))
+ #define __SOURCELOC__ (sprintf("^7%s^9(^9%s^7:^9%s^7)\n", __FUNC__, __FILE__, STR(__LINE__)))
#endif
-#define _LOG_PREFIX(level) strcat("^9[::^7", PROGNAME, "^9::", level, "^9] ")
-#define _LOG_HEADER(level) strcat(_LOG_PREFIX(level), __SOURCELOC__, "\n")
+#define _LOG_HEADER(level, full) strcat("^9[::^7", PROGNAME, "^9::", level, "^9] ", ((full) ? __SOURCELOC__ : ""))
+
#define _LOG(func_header, level, func_msg, s) \
MACRO_BEGIN \
- func_header(autocvar_developer > 0 ? _LOG_HEADER(level) : _LOG_PREFIX(level)); \
+ func_header(_LOG_HEADER(level, autocvar_developer > 0)); \
func_msg(strcat("^7", s, "\n")); \
MACRO_END
#define LOG_INFOF(...) _LOG_INFO(sprintf(__VA_ARGS__))
#define _LOG_INFO(s) \
MACRO_BEGIN \
- if (autocvar_developer > 1) print(_LOG_HEADER("^5INFO")); \
- else if (autocvar_developer > 0) print(_LOG_PREFIX("^5INFO")); \
+ if (autocvar_developer > 0) print(_LOG_HEADER("^5INFO", autocvar_developer > 1)); \
string __s = s; \
print("^7", __s); \
/* TODO: unconditionally add a newline when possible */ \