]> granicus.if.org Git - postgresql/commitdiff
> Yikes, that is certainly not standard C. I have never seen that
authorBruce Momjian <bruce@momjian.us>
Thu, 3 Sep 1998 02:20:30 +0000 (02:20 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 3 Sep 1998 02:20:30 +0000 (02:20 +0000)
before.
> Looks like a GNU-ism.  I nice one, but still a GNU-ism.

Sorry, I didn't know it is a GNU extension. I have written this patch
which should fix the problem. Let me know if you still have problems.

Massimo Dal Zotto

src/backend/utils/misc/trace.c
src/include/utils/trace.h

index 527f041e098c392979a0e4140e3021a3e1a32200..fb3289d7bc181fc9076ec3fa71209288722b60a6 100644 (file)
@@ -129,6 +129,34 @@ tprintf(int flag, const char *fmt,...)
        return 1;
 }
 
+/*
+ * Print a timestamp and a message to stdout or to syslog.
+ */
+int
+tprintf1(const char *fmt, ... )
+{
+       va_list         ap;
+       char            line[ELOG_MAXLEN+TIMESTAMP_SIZE+1];
+
+       va_start(ap, fmt);
+#ifdef ELOG_TIMESTAMPS
+       strcpy(line, tprintf_timestamp());
+#endif
+       vsprintf(line+TIMESTAMP_SIZE, fmt, ap);
+       va_end(ap);
+
+#ifdef USE_SYSLOG
+       write_syslog(LOG_INFO, line+TIMESTAMP_SIZE);
+#endif
+
+       if (UseSyslog <= 1) {
+               puts(line);
+               fflush(stdout);
+       }
+
+       return 1;
+}
+
 /*
  * Print a timestamp and a message to stderr.
  */
index 4d71b20ea21c49957efc8f5057d49a39e04f4f1a..8f716393c67028aeb9f906901e35046098f570f5 100644 (file)
@@ -27,6 +27,7 @@ char     *tprintf_timestamp(void);
 #define TIMESTAMP_SIZE 0
 #endif
 
+extern int     tprintf1(const char *fmt, ...);
 extern int     tprintf(int flag, const char *fmt,...);
 extern int     eprintf(const char *fmt,...);
 extern int     option_flag(int flag);
@@ -75,9 +76,15 @@ enum pg_option_enum
 
 extern int     pg_options[NUM_PG_OPTIONS];
 
-#define PRINTF(args...)                        tprintf(TRACE_ALL, args)
-#define EPRINTF(args...)               eprintf(args)
+#ifdef __GNUC__
+#define PRINTF(args...)                        tprintf1(args)
+#define EPRINTF(args...)               eprintf(args)
 #define TPRINTF(flag, args...) tprintf(flag, args)
+#else
+#define PRINTF tprintf1
+#define EPRINTF eprintf
+#define TPRINTF        tprintf
+#endif
 
 #endif  /* TRACE_H */