|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.101 2002/09/0202:47:05 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.102 2002/09/0205:42:54 momjian Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
|
33 | 33 | #include"storage/proc.h" |
34 | 34 | #include"tcop/tcopprot.h" |
35 | 35 | #include"utils/memutils.h" |
| 36 | +#include"utils/guc.h" |
36 | 37 |
|
37 | 38 | #include"mb/pg_wchar.h" |
38 | 39 |
|
39 | | -intserver_min_messages; |
40 | | -char*server_min_messages_str=NULL; |
41 | | -constcharserver_min_messages_str_default[]="notice"; |
42 | | - |
43 | | -intclient_min_messages; |
44 | | -char*client_min_messages_str=NULL; |
45 | | -constcharclient_min_messages_str_default[]="notice"; |
46 | | - |
47 | 40 | #ifdefHAVE_SYSLOG |
48 | 41 | /* |
49 | 42 | * 0 = only stdout/stderr |
@@ -345,6 +338,7 @@ elog(int lev, const char *fmt,...) |
345 | 338 | } |
346 | 339 | } |
347 | 340 |
|
| 341 | + |
348 | 342 | /* |
349 | 343 | * Message prepared; send it where it should go |
350 | 344 | */ |
@@ -433,6 +427,14 @@ elog(int lev, const char *fmt,...) |
433 | 427 | if (msg_buf!=msg_fixedbuf) |
434 | 428 | free(msg_buf); |
435 | 429 |
|
| 430 | +/* If the user wants this elog() generating query logged, |
| 431 | + * do so. We only want to log if the query has been |
| 432 | + * written to debug_query_string. Also, avoid infinite loops. |
| 433 | + */ |
| 434 | + |
| 435 | +if(lev!=LOG&&lev >=log_min_error_statement&&debug_query_string) |
| 436 | +elog(LOG,"statement: %s",debug_query_string); |
| 437 | + |
436 | 438 | /* |
437 | 439 | * Perform error recovery action as specified by lev. |
438 | 440 | */ |
@@ -835,71 +837,4 @@ elog_message_prefix(int lev) |
835 | 837 | } |
836 | 838 |
|
837 | 839 |
|
838 | | -/* |
839 | | - * GUC support routines |
840 | | - */ |
841 | | -constchar* |
842 | | -assign_server_min_messages(constchar*newval, |
843 | | -booldoit,boolinteractive) |
844 | | -{ |
845 | | -if (strcasecmp(newval,"debug")==0) |
846 | | -{if (doit)server_min_messages=DEBUG1; } |
847 | | -elseif (strcasecmp(newval,"debug5")==0) |
848 | | -{if (doit)server_min_messages=DEBUG5; } |
849 | | -elseif (strcasecmp(newval,"debug4")==0) |
850 | | -{if (doit)server_min_messages=DEBUG4; } |
851 | | -elseif (strcasecmp(newval,"debug3")==0) |
852 | | -{if (doit)server_min_messages=DEBUG3; } |
853 | | -elseif (strcasecmp(newval,"debug2")==0) |
854 | | -{if (doit)server_min_messages=DEBUG2; } |
855 | | -elseif (strcasecmp(newval,"debug1")==0) |
856 | | -{if (doit)server_min_messages=DEBUG1; } |
857 | | -elseif (strcasecmp(newval,"info")==0) |
858 | | -{if (doit)server_min_messages=INFO; } |
859 | | -elseif (strcasecmp(newval,"notice")==0) |
860 | | -{if (doit)server_min_messages=NOTICE; } |
861 | | -elseif (strcasecmp(newval,"warning")==0) |
862 | | -{if (doit)server_min_messages=WARNING; } |
863 | | -elseif (strcasecmp(newval,"error")==0) |
864 | | -{if (doit)server_min_messages=ERROR; } |
865 | | -elseif (strcasecmp(newval,"log")==0) |
866 | | -{if (doit)server_min_messages=LOG; } |
867 | | -elseif (strcasecmp(newval,"fatal")==0) |
868 | | -{if (doit)server_min_messages=FATAL; } |
869 | | -elseif (strcasecmp(newval,"panic")==0) |
870 | | -{if (doit)server_min_messages=PANIC; } |
871 | | -else |
872 | | -returnNULL;/* fail */ |
873 | | -returnnewval;/* OK */ |
874 | | -} |
875 | 840 |
|
876 | | -constchar* |
877 | | -assign_client_min_messages(constchar*newval, |
878 | | -booldoit,boolinteractive) |
879 | | -{ |
880 | | -if (strcasecmp(newval,"debug")==0) |
881 | | -{if (doit)client_min_messages=DEBUG1; } |
882 | | -elseif (strcasecmp(newval,"debug5")==0) |
883 | | -{if (doit)client_min_messages=DEBUG5; } |
884 | | -elseif (strcasecmp(newval,"debug4")==0) |
885 | | -{if (doit)client_min_messages=DEBUG4; } |
886 | | -elseif (strcasecmp(newval,"debug3")==0) |
887 | | -{if (doit)client_min_messages=DEBUG3; } |
888 | | -elseif (strcasecmp(newval,"debug2")==0) |
889 | | -{if (doit)client_min_messages=DEBUG2; } |
890 | | -elseif (strcasecmp(newval,"debug1")==0) |
891 | | -{if (doit)client_min_messages=DEBUG1; } |
892 | | -elseif (strcasecmp(newval,"log")==0) |
893 | | -{if (doit)client_min_messages=LOG; } |
894 | | -elseif (strcasecmp(newval,"info")==0) |
895 | | -{if (doit)client_min_messages=INFO; } |
896 | | -elseif (strcasecmp(newval,"notice")==0) |
897 | | -{if (doit)client_min_messages=NOTICE; } |
898 | | -elseif (strcasecmp(newval,"warning")==0) |
899 | | -{if (doit)client_min_messages=WARNING; } |
900 | | -elseif (strcasecmp(newval,"error")==0) |
901 | | -{if (doit)client_min_messages=ERROR; } |
902 | | -else |
903 | | -returnNULL;/* fail */ |
904 | | -returnnewval;/* OK */ |
905 | | -} |