Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d318315

Browse files
committed
> 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
1 parent 9fbaf1d commit d318315

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/backend/utils/misc/trace.c

+28
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,34 @@ tprintf(int flag, const char *fmt,...)
129129
return 1;
130130
}
131131

132+
/*
133+
* Print a timestamp and a message to stdout or to syslog.
134+
*/
135+
int
136+
tprintf1(const char *fmt, ... )
137+
{
138+
va_list ap;
139+
char line[ELOG_MAXLEN+TIMESTAMP_SIZE+1];
140+
141+
va_start(ap, fmt);
142+
#ifdef ELOG_TIMESTAMPS
143+
strcpy(line, tprintf_timestamp());
144+
#endif
145+
vsprintf(line+TIMESTAMP_SIZE, fmt, ap);
146+
va_end(ap);
147+
148+
#ifdef USE_SYSLOG
149+
write_syslog(LOG_INFO, line+TIMESTAMP_SIZE);
150+
#endif
151+
152+
if (UseSyslog <= 1) {
153+
puts(line);
154+
fflush(stdout);
155+
}
156+
157+
return 1;
158+
}
159+
132160
/*
133161
* Print a timestamp and a message to stderr.
134162
*/

src/include/utils/trace.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ char *tprintf_timestamp(void);
2727
#define TIMESTAMP_SIZE 0
2828
#endif
2929

30+
extern int tprintf1(const char *fmt, ...);
3031
extern int tprintf(int flag, const char *fmt,...);
3132
extern int eprintf(const char *fmt,...);
3233
extern int option_flag(int flag);
@@ -75,9 +76,15 @@ enum pg_option_enum
7576

7677
extern int pg_options[NUM_PG_OPTIONS];
7778

78-
#define PRINTF(args...) tprintf(TRACE_ALL, args)
79-
#define EPRINTF(args...) eprintf(args)
79+
#ifdef __GNUC__
80+
#define PRINTF(args...) tprintf1(args)
81+
#define EPRINTF(args...) eprintf(args)
8082
#define TPRINTF(flag, args...) tprintf(flag, args)
83+
#else
84+
#define PRINTF tprintf1
85+
#define EPRINTF eprintf
86+
#define TPRINTF tprintf
87+
#endif
8188

8289
#endif /* TRACE_H */
8390

0 commit comments

Comments
 (0)