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