summaryrefslogtreecommitdiff
path: root/src/include/utils/trace.h
blob: d978f16ab4443f9c07c5b89b97651dd2679b8ce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*-------------------------------------------------------------------------
 *
 * trace.h--
 *
 *	  Conditional trace definitions.
 *
 *	  Massimo Dal Zotto <dz@cs.unitn.it>
 *
 *-------------------------------------------------------------------------
 */

#ifndef TRACE_H
#define TRACE_H

#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdarg.h>

#include "postgres.h"

#ifdef ELOG_TIMESTAMPS
char	   *tprintf_timestamp(void);

#define TIMESTAMP_SIZE 28
#else
#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);
extern int	set_option_flag(int flag, int value);
extern void write_syslog(int level, char *line);
extern void parse_options(char *str);
extern void read_pg_options(SIGNAL_ARGS);

/*
 * Trace options, used as index into pg_options.
 * Must match the constants in pg_options[].
 */
enum pg_option_enum
{
	TRACE_ALL,					/* 0=trace some, 1=trace all, -1=trace
								 * none */
	TRACE_VERBOSE,
	TRACE_QUERY,
	TRACE_PLAN,
	TRACE_PARSE,
	TRACE_REWRITTEN,
	TRACE_PARSERSTATS,
	TRACE_PLANNERSTATS,
	TRACE_EXECUTORSTATS,
	TRACE_SHORTLOCKS,			/* currently unused but needed, see lock.c */
	TRACE_LOCKS,
	TRACE_USERLOCKS,
	TRACE_SPINLOCKS,
	TRACE_NOTIFY,
	TRACE_MALLOC,
	TRACE_PALLOC,
	TRACE_LOCKOIDMIN,
	TRACE_LOCKRELATION,
	OPT_LOCKREADPRIORITY,		/* lock priority, see lock.c */
	OPT_DEADLOCKTIMEOUT,		/* deadlock timeout, see proc.c */
	OPT_SYSLOG,					/* use syslog for error messages */
	OPT_HOSTLOOKUP,				/* enable hostname lookup in ps_status */
	OPT_SHOWPORTNUMBER,			/* show port number in ps_status */

	NUM_PG_OPTIONS				/* must be the last item of enum */
};

extern int	pg_options[NUM_PG_OPTIONS];

#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 */

/*
 * Local variables:
 *	tab-width: 4
 *	c-indent-level: 4
 *	c-basic-offset: 4
 * End:
 */