summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian1998-09-03 02:20:30 +0000
committerBruce Momjian1998-09-03 02:20:30 +0000
commitd318315200e31b886b57caeeb4d4ea81112730aa (patch)
tree19dcbaa5384d4f7fc46602bfd742d27e0b998b42
parent9fbaf1d851ff90c803cb8dcadd96095d76a44fb0 (diff)
> Yikes, that is certainly not standard C. I have never seen that
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
-rw-r--r--src/backend/utils/misc/trace.c28
-rw-r--r--src/include/utils/trace.h11
2 files changed, 37 insertions, 2 deletions
diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c
index 527f041e098..fb3289d7bc1 100644
--- a/src/backend/utils/misc/trace.c
+++ b/src/backend/utils/misc/trace.c
@@ -130,6 +130,34 @@ tprintf(int flag, const char *fmt,...)
}
/*
+ * 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.
*/
int
diff --git a/src/include/utils/trace.h b/src/include/utils/trace.h
index 4d71b20ea21..8f716393c67 100644
--- a/src/include/utils/trace.h
+++ b/src/include/utils/trace.h
@@ -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 */