changed to work with different compiler-specific ways of doing macro
2007-11-18 Michael Natterer <mitch@gimp.org> * app/gimp-log.[ch]: changed to work with different compiler-specific ways of doing macro varargs also cope with no macro vararg support at all. Pointed out by Hans Breuer. svn path=/trunk/; revision=24184
This commit is contained in:

committed by
Michael Natterer

parent
bcb2a4e942
commit
f98e9de791
@ -1,3 +1,9 @@
|
|||||||
|
2007-11-18 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/gimp-log.[ch]: changed to work with different
|
||||||
|
compiler-specific ways of doing macro varargs also cope with no
|
||||||
|
macro vararg support at all. Pointed out by Hans Breuer.
|
||||||
|
|
||||||
2007-11-18 Michael Natterer <mitch@gimp.org>
|
2007-11-18 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/display/gimpdisplayshell-callbacks.c
|
* app/display/gimpdisplayshell-callbacks.c
|
||||||
|
@ -52,21 +52,27 @@ gimp_log (const gchar *function,
|
|||||||
const gchar *domain,
|
const gchar *domain,
|
||||||
const gchar *format,
|
const gchar *format,
|
||||||
...)
|
...)
|
||||||
{
|
|
||||||
gchar *message;
|
|
||||||
|
|
||||||
if (format)
|
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
va_start (args, format);
|
va_start (args, format);
|
||||||
message = g_strdup_vprintf (format, args);
|
gimp_logv (function, line, domain, format, args);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
void
|
||||||
|
gimp_logv (const gchar *function,
|
||||||
|
gint line,
|
||||||
|
const gchar *domain,
|
||||||
|
const gchar *format,
|
||||||
|
va_list args)
|
||||||
{
|
{
|
||||||
|
gchar *message;
|
||||||
|
|
||||||
|
if (format)
|
||||||
|
message = g_strdup_vprintf (format, args);
|
||||||
|
else
|
||||||
message = g_strdup ("called");
|
message = g_strdup ("called");
|
||||||
}
|
|
||||||
|
|
||||||
g_log (domain, G_LOG_LEVEL_DEBUG,
|
g_log (domain, G_LOG_LEVEL_DEBUG,
|
||||||
"%s(%d): %s", function, line, message);
|
"%s(%d): %s", function, line, message);
|
||||||
|
@ -28,12 +28,39 @@ typedef enum
|
|||||||
} GimpLogFlags;
|
} GimpLogFlags;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef G_HAVE_ISO_VARARGS
|
||||||
|
|
||||||
|
#define GIMP_LOG(type, ...) \
|
||||||
|
G_STMT_START { \
|
||||||
|
if (gimp_log_flags & GIMP_LOG_##type) \
|
||||||
|
gimp_log (G_STRFUNC, __LINE__, #type, __VA_ARGS__); \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
#elif defined(G_HAVE_GNUC_VARARGS)
|
||||||
|
|
||||||
#define GIMP_LOG(type, format...) \
|
#define GIMP_LOG(type, format...) \
|
||||||
G_STMT_START { \
|
G_STMT_START { \
|
||||||
if (gimp_log_flags & GIMP_LOG_##type) \
|
if (gimp_log_flags & GIMP_LOG_##type) \
|
||||||
gimp_log (G_STRFUNC, __LINE__, #type, format); \
|
gimp_log (G_STRFUNC, __LINE__, #type, format); \
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
|
#else /* no varargs macros */
|
||||||
|
|
||||||
|
static void
|
||||||
|
GIMP_LOG (const gchar *function,
|
||||||
|
gint line,
|
||||||
|
const gchar *domain,
|
||||||
|
const gchar *format,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start (args, format);
|
||||||
|
gimp_logv (function, line, domain, format, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !__GNUC__ */
|
||||||
|
|
||||||
|
|
||||||
extern GimpLogFlags gimp_log_flags;
|
extern GimpLogFlags gimp_log_flags;
|
||||||
|
|
||||||
@ -44,6 +71,11 @@ void gimp_log (const gchar *function,
|
|||||||
const gchar *domain,
|
const gchar *domain,
|
||||||
const gchar *format,
|
const gchar *format,
|
||||||
...) G_GNUC_PRINTF (4, 5);
|
...) G_GNUC_PRINTF (4, 5);
|
||||||
|
void gimp_logv (const gchar *function,
|
||||||
|
gint line,
|
||||||
|
const gchar *domain,
|
||||||
|
const gchar *format,
|
||||||
|
va_list args);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_LOG_H__ */
|
#endif /* __GIMP_LOG_H__ */
|
||||||
|
Reference in New Issue
Block a user