aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/misc/trace.c')
-rw-r--r--src/backend/utils/misc/trace.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c
index baf8ce61218..3d9cbe607de 100644
--- a/src/backend/utils/misc/trace.c
+++ b/src/backend/utils/misc/trace.c
@@ -2,22 +2,21 @@
*
* trace.c
*
- * Conditional trace ans logging functions.
+ * Conditional trace and logging functions.
*
* Massimo Dal Zotto <dz@cs.unitn.it>
*
*-------------------------------------------------------------------------
*/
+#include "postgres.h"
+
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-
-#include "postgres.h"
-
#ifdef USE_SYSLOG
#include <syslog.h>
#endif
@@ -25,6 +24,13 @@
#include "miscadmin.h"
#include "utils/trace.h"
+/*
+ * We could support trace messages of indefinite length, as elog() does,
+ * but it's probably not worth the trouble. Instead limit trace message
+ * length to this.
+ */
+#define TRACEMSG_MAXLEN 1024
+
#ifdef USE_SYSLOG
/*
* Global option to control the use of syslog(3) for logging:
@@ -87,15 +93,14 @@ int
tprintf(int flag, const char *fmt,...)
{
va_list ap;
- char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1];
-
+ char line[TRACEMSG_MAXLEN + TIMESTAMP_SIZE + 1];
#ifdef USE_SYSLOG
int log_level;
#endif
if ((flag == TRACE_ALL) || (pg_options[TRACE_ALL] > 0))
{
- /* uconditional trace or trace all option set */
+ /* unconditional trace or trace all option set */
}
else if (pg_options[TRACE_ALL] == 0)
{
@@ -105,11 +110,11 @@ tprintf(int flag, const char *fmt,...)
else if (pg_options[TRACE_ALL] < 0)
return 0;
- va_start(ap, fmt);
#ifdef ELOG_TIMESTAMPS
strcpy(line, tprintf_timestamp());
#endif
- vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
+ va_start(ap, fmt);
+ vsnprintf(line + TIMESTAMP_SIZE, TRACEMSG_MAXLEN, fmt, ap);
va_end(ap);
#ifdef USE_SYSLOG
@@ -134,13 +139,13 @@ int
tprintf1(const char *fmt,...)
{
va_list ap;
- char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1];
+ char line[TRACEMSG_MAXLEN + TIMESTAMP_SIZE + 1];
- va_start(ap, fmt);
#ifdef ELOG_TIMESTAMPS
strcpy(line, tprintf_timestamp());
#endif
- vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
+ va_start(ap, fmt);
+ vsnprintf(line + TIMESTAMP_SIZE, TRACEMSG_MAXLEN, fmt, ap);
va_end(ap);
#ifdef USE_SYSLOG
@@ -164,13 +169,13 @@ int
eprintf(const char *fmt,...)
{
va_list ap;
- char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1];
+ char line[TRACEMSG_MAXLEN + TIMESTAMP_SIZE + 1];
- va_start(ap, fmt);
#ifdef ELOG_TIMESTAMPS
strcpy(line, tprintf_timestamp());
#endif
- vsnprintf(line + TIMESTAMP_SIZE, ELOG_MAXLEN, fmt, ap);
+ va_start(ap, fmt);
+ vsnprintf(line + TIMESTAMP_SIZE, TRACEMSG_MAXLEN, fmt, ap);
va_end(ap);
#ifdef USE_SYSLOG