]> granicus.if.org Git - postgresql/blob - src/include/utils/elog.h
acb820497309d4fea4ba2f876c84fc583a18c57c
[postgresql] / src / include / utils / elog.h
1 /*-------------------------------------------------------------------------
2  *
3  * elog.h
4  *        POSTGRES error logging definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: elog.h,v 1.20 2000/12/06 17:25:45 tgl Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef ELOG_H
15 #define ELOG_H
16
17 #define NOTICE  0                               /* random info - no special action */
18 #define ERROR   (-1)                    /* user error - return to known state */
19 #define FATAL   1                               /* fatal error - abort process */
20 #define REALLYFATAL 2                   /* take down the other backends with me */
21 #define STOP    REALLYFATAL
22 #define DEBUG   (-2)                    /* debug message */
23 #define LOG             DEBUG
24 #define NOIND   (-3)                    /* debug message, don't indent as far */
25
26 #ifdef ENABLE_SYSLOG
27 extern int Use_syslog;
28 #endif
29
30 /*
31  * If StopIfError > 0 signal handlers mustn't do
32  * elog(ERROR|FATAL), instead remember what action is
33  * required with QueryCancel & ExitAfterAbort.
34  */
35 extern uint32 StopIfError;              /* duplicates access/xlog.h */
36 extern bool QueryCancel;                /* duplicates miscadmin.h */
37 extern bool     ExitAfterAbort;
38
39 #define START_CRIT_CODE         (StopIfError++)
40
41 #define END_CRIT_CODE   \
42         do { \
43                 if (!StopIfError) \
44                         elog(STOP, "Not in critical section"); \
45                 StopIfError--; \
46                 if (!StopIfError && QueryCancel) \
47                 { \
48                         if (ExitAfterAbort) \
49                                 elog(FATAL, "The system is shutting down"); \
50                         else \
51                                 elog(ERROR, "Query was cancelled."); \
52                 } \
53         } while(0)
54
55 extern bool Log_timestamp;
56 extern bool Log_pid;
57
58 #ifndef __GNUC__
59 extern void elog(int lev, const char *fmt,...);
60
61 #else
62 /* This extension allows gcc to check the format string for consistency with
63    the supplied arguments. */
64 extern void elog(int lev, const char *fmt,...) __attribute__((format(printf, 2, 3)));
65
66 #endif
67
68 #ifndef PG_STANDALONE
69 extern int      DebugFileOpen(void);
70
71 #endif
72
73 #endif   /* ELOG_H */