// is assigned a particular log level.
#define DEF_LOGFUNCTION(name, level) \
- inline void v##name(const char* fmt, va_list ap) { \
- if (m_log && (level <= m_level)) \
- m_log->write(level, m_name, fmt, ap);\
+ inline void v##name(const char* fmt, va_list ap) __printf_attr(2, 0) { \
+ if (m_log && (level <= m_level)) \
+ m_log->write(level, m_name, fmt, ap); \
} \
inline void name(const char* fmt, ...) __printf_attr(2, 3) { \
if (m_log && (level <= m_level)) { \
// and is attached to a particular Logger instance and
// is assigned a particular log level.
+#ifdef __GNUC__
+# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b)))
+#else
+# define __printf_attr(a, b)
+#endif // __GNUC__
+
namespace rfb {
class Logger {
// -=- Write data to a log
virtual void write(int level, const char *logname, const char *text) = 0;
- void write(int level, const char *logname, const char* format, va_list ap);
+ void write(int level, const char *logname, const char* format, va_list ap) __printf_attr(4, 0);
// -=- Register a logger