va_end(ap);
}
+
/** Output a message to the log, prefixed with a function name <b>fn</b>. */
+#ifdef __GNUC__
void _log_fn(int severity, const char *fn, const char *format, ...)
{
va_list ap;
logv(severity, fn, format, ap);
va_end(ap);
}
+#else
+const char *_log_fn_function_name=NULL;
+void _log_fn(int severity, const char *format, ...)
+{
+ va_list ap;
+ va_start(ap,format);
+ logv(severity, _log_fn_function_name, format, ap);
+ va_end(ap);
+ _log_fn_function_name = NULL;
+}
+#endif
/** Close all open log files. */
void close_logs()
#define log_fn(severity, args...) \
_log_fn(severity, __PRETTY_FUNCTION__, args)
#else
-#define log_fn _log
+/* We don't have GCC's varargs macros, so use a global variable to pass the
+ * function name to log_fn */
+extern const char *_log_fn_function_name;
+void _log_fn(int severity, const char *format, ...);
+/* We abuse the comma operator here, since we can't use the standard
+ * do {...} while(0) trick to wrap this macro, since the macro can't take
+ * arguments. */
+#define log_fn (_log_fn_function_name=__FUNCTION__),_log_fn
#endif
#define log _log /* hack it so we don't conflict with log() as much */