diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-03-02 21:39:36 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-03-02 21:39:36 +0000 |
commit | a033daf5663944872080f1f52deb2ffcb40f4042 (patch) | |
tree | 660da56fcf1f2d1f9e8ea31610f741bed3a8d778 /src/backend/utils | |
parent | 8d8aa931ef5a3489764de222b1bfe43463d58a13 (diff) | |
download | postgresql-a033daf5663944872080f1f52deb2ffcb40f4042.tar.gz postgresql-a033daf5663944872080f1f52deb2ffcb40f4042.zip |
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/adt/acl.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/format_type.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/pg_locale.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 4 | ||||
-rw-r--r-- | src/backend/utils/cache/catcache.c | 50 | ||||
-rw-r--r-- | src/backend/utils/error/elog.c | 216 | ||||
-rw-r--r-- | src/backend/utils/fmgr/dfmgr.c | 5 | ||||
-rw-r--r-- | src/backend/utils/hash/dynahash.c | 4 | ||||
-rw-r--r-- | src/backend/utils/init/findbe.c | 39 | ||||
-rw-r--r-- | src/backend/utils/init/globals.c | 4 | ||||
-rw-r--r-- | src/backend/utils/init/miscinit.c | 10 | ||||
-rw-r--r-- | src/backend/utils/misc/guc-file.l | 4 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 27 | ||||
-rw-r--r-- | src/backend/utils/misc/postgresql.conf.sample | 9 |
14 files changed, 279 insertions, 109 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index ef6ebba7fa7..f868b36861d 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.67 2002/02/18 23:11:22 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.68 2002/03/02 21:39:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -122,7 +122,7 @@ aclparse(const char *s, AclItem *aip, unsigned *modechg) Assert(s && aip && modechg); #ifdef ACLDEBUG - elog(DEBUG, "aclparse: input = '%s'", s); + elog(LOG, "aclparse: input = '%s'", s); #endif aip->ai_idtype = ACL_IDTYPE_UID; s = getid(s, name); @@ -204,7 +204,7 @@ aclparse(const char *s, AclItem *aip, unsigned *modechg) } #ifdef ACLDEBUG - elog(DEBUG, "aclparse: correctly read [%x %d %x], modechg=%x", + elog(LOG, "aclparse: correctly read [%x %d %x], modechg=%x", aip->ai_idtype, aip->ai_id, aip->ai_mode, *modechg); #endif return s; diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c index 3bd7232c2f8..960d0b2bcf0 100644 --- a/src/backend/utils/adt/format_type.c +++ b/src/backend/utils/adt/format_type.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.23 2001/11/19 19:51:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.24 2002/03/02 21:39:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -294,7 +294,7 @@ format_type_internal(Oid type_oid, int32 typemod, fieldstr = ""; break; default: - elog(DEBUG, "Invalid INTERVAL typmod 0x%x", typemod); + elog(LOG, "Invalid INTERVAL typmod 0x%x", typemod); fieldstr = ""; break; } diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index fd4b9c37197..9952f01714a 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -4,7 +4,7 @@ * The PostgreSQL locale utils. * * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.13 2001/11/05 17:46:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.14 2002/03/02 21:39:32 momjian Exp $ * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group * @@ -86,7 +86,7 @@ static void PGLC_debug_lc(PG_LocaleCategories *lc) { #ifdef LC_MESSAGES - elog(DEBUG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\nLC_MESSAGES:\t%s\n", + elog(LOG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\nLC_MESSAGES:\t%s\n", lc->lang, lc->lc_ctype, lc->lc_numeric, @@ -95,7 +95,7 @@ PGLC_debug_lc(PG_LocaleCategories *lc) lc->lc_monetary, lc->lc_messages); #else - elog(DEBUG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\n", + elog(LOG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\n", lc->lang, lc->lc_ctype, lc->lc_numeric, diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 6f08deec5a1..a6f9bf6b60d 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.104 2002/03/01 04:09:25 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.105 2002/03/02 21:39:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -3169,7 +3169,7 @@ locale_is_like_safe(void) return (bool) result; localeptr = setlocale(LC_COLLATE, NULL); if (!localeptr) - elog(STOP, "Invalid LC_COLLATE setting"); + elog(PANIC, "Invalid LC_COLLATE setting"); /* * Currently we accept only "C" and "POSIX" (do any systems still diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 4339f51f3d7..b79d6712559 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.88 2002/02/25 04:06:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.89 2002/03/02 21:39:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -146,14 +146,14 @@ CatCachePrintStats(void) long cc_hits = 0; long cc_newloads = 0; - elog(DEBUG, "Catcache stats dump: %d/%d tuples in catcaches", + elog(LOG, "Catcache stats dump: %d/%d tuples in catcaches", CacheHdr->ch_ntup, CacheHdr->ch_maxtup); for (cache = CacheHdr->ch_caches; cache; cache = cache->cc_next) { if (cache->cc_ntup == 0 && cache->cc_searches == 0) continue; /* don't print unused caches */ - elog(DEBUG, "Catcache %s/%s: %d tup, %ld srch, %ld hits, %ld loads, %ld not found", + elog(LOG, "Catcache %s/%s: %d tup, %ld srch, %ld hits, %ld loads, %ld not found", cache->cc_relname, cache->cc_indname, cache->cc_ntup, @@ -165,7 +165,7 @@ CatCachePrintStats(void) cc_hits += cache->cc_hits; cc_newloads += cache->cc_newloads; } - elog(DEBUG, "Catcache totals: %d tup, %ld srch, %ld hits, %ld loads, %ld not found", + elog(LOG, "Catcache totals: %d tup, %ld srch, %ld hits, %ld loads, %ld not found", CacheHdr->ch_ntup, cc_searches, cc_hits, @@ -208,17 +208,17 @@ CreateCacheMemoryContext(void) */ #ifdef CACHEDEBUG #define CatalogCacheInitializeCache_DEBUG1 \ - elog(DEBUG, "CatalogCacheInitializeCache: cache @%p %s", cache, \ + elog(LOG, "CatalogCacheInitializeCache: cache @%p %s", cache, \ cache->cc_relname) #define CatalogCacheInitializeCache_DEBUG2 \ do { \ if (cache->cc_key[i] > 0) { \ - elog(DEBUG, "CatalogCacheInitializeCache: load %d/%d w/%d, %u", \ + elog(LOG, "CatalogCacheInitializeCache: load %d/%d w/%d, %u", \ i+1, cache->cc_nkeys, cache->cc_key[i], \ tupdesc->attrs[cache->cc_key[i] - 1]->atttypid); \ } else { \ - elog(DEBUG, "CatalogCacheInitializeCache: load %d/%d w/%d", \ + elog(LOG, "CatalogCacheInitializeCache: load %d/%d w/%d", \ i+1, cache->cc_nkeys, cache->cc_key[i]); \ } \ } while(0) @@ -270,7 +270,7 @@ CatalogCacheInitializeCache(CatCache *cache) heap_close(relation, NoLock); - CACHE3_elog(DEBUG, "CatalogCacheInitializeCache: %s, %d keys", + CACHE3_elog(LOG, "CatalogCacheInitializeCache: %s, %d keys", cache->cc_relname, cache->cc_nkeys); /* @@ -306,7 +306,7 @@ CatalogCacheInitializeCache(CatCache *cache) /* Initialize sk_attno suitably for HeapKeyTest() and heap scans */ cache->cc_skey[i].sk_attno = cache->cc_key[i]; - CACHE4_elog(DEBUG, "CatalogCacheInit %s %d %p", + CACHE4_elog(LOG, "CatalogCacheInit %s %d %p", cache->cc_relname, i, cache); @@ -350,7 +350,7 @@ CatalogCacheComputeHashIndex(CatCache *cache, ScanKey cur_skey) { uint32 hashIndex = 0; - CACHE4_elog(DEBUG, "CatalogCacheComputeHashIndex %s %d %p", + CACHE4_elog(LOG, "CatalogCacheComputeHashIndex %s %d %p", cache->cc_relname, cache->cc_nkeys, cache); @@ -491,7 +491,7 @@ CatalogCacheIdInvalidate(int cacheId, * sanity checks */ Assert(ItemPointerIsValid(pointer)); - CACHE1_elog(DEBUG, "CatalogCacheIdInvalidate: called"); + CACHE1_elog(LOG, "CatalogCacheIdInvalidate: called"); /* * inspect caches to find the proper cache @@ -521,7 +521,7 @@ CatalogCacheIdInvalidate(int cacheId, ct->dead = true; else CatCacheRemoveCTup(ccp, ct); - CACHE1_elog(DEBUG, "CatalogCacheIdInvalidate: invalidated"); + CACHE1_elog(LOG, "CatalogCacheIdInvalidate: invalidated"); /* could be multiple matches, so keep looking! */ } } @@ -623,12 +623,12 @@ ResetCatalogCaches(void) { CatCache *cache; - CACHE1_elog(DEBUG, "ResetCatalogCaches called"); + CACHE1_elog(LOG, "ResetCatalogCaches called"); for (cache = CacheHdr->ch_caches; cache; cache = cache->cc_next) ResetCatalogCache(cache); - CACHE1_elog(DEBUG, "end of ResetCatalogCaches call"); + CACHE1_elog(LOG, "end of ResetCatalogCaches call"); } /* @@ -656,7 +656,7 @@ CatalogCacheFlushRelation(Oid relId) { CatCache *cache; - CACHE2_elog(DEBUG, "CatalogCacheFlushRelation called for %u", relId); + CACHE2_elog(LOG, "CatalogCacheFlushRelation called for %u", relId); for (cache = CacheHdr->ch_caches; cache; cache = cache->cc_next) { @@ -716,7 +716,7 @@ CatalogCacheFlushRelation(Oid relId) } } - CACHE1_elog(DEBUG, "end of CatalogCacheFlushRelation call"); + CACHE1_elog(LOG, "end of CatalogCacheFlushRelation call"); } /* @@ -730,7 +730,7 @@ CatalogCacheFlushRelation(Oid relId) #ifdef CACHEDEBUG #define InitCatCache_DEBUG1 \ do { \ - elog(DEBUG, "InitCatCache: rel=%s id=%d nkeys=%d size=%d\n", \ + elog(LOG, "InitCatCache: rel=%s id=%d nkeys=%d size=%d\n", \ cp->cc_relname, cp->id, cp->cc_nkeys, cp->cc_size); \ } while(0) @@ -958,7 +958,7 @@ SearchCatCache(CatCache *cache, DLMoveToFront(&ct->cache_elem); #ifdef CACHEDEBUG - CACHE3_elog(DEBUG, "SearchCatCache(%s): found in bucket %d", + CACHE3_elog(LOG, "SearchCatCache(%s): found in bucket %d", cache->cc_relname, hash); #endif /* CACHEDEBUG */ @@ -1006,7 +1006,7 @@ SearchCatCache(CatCache *cache, Buffer buffer; int i; - CACHE2_elog(DEBUG, "SearchCatCache(%s): performing index scan", + CACHE2_elog(LOG, "SearchCatCache(%s): performing index scan", cache->cc_relname); /* @@ -1045,7 +1045,7 @@ SearchCatCache(CatCache *cache, { HeapScanDesc sd; - CACHE2_elog(DEBUG, "SearchCatCache(%s): performing heap scan", + CACHE2_elog(LOG, "SearchCatCache(%s): performing heap scan", cache->cc_relname); sd = heap_beginscan(relation, 0, SnapshotNow, @@ -1081,7 +1081,7 @@ SearchCatCache(CatCache *cache, * Finish initializing the CatCTup header, and add it to the linked * lists. */ - CACHE1_elog(DEBUG, "SearchCatCache: found tuple"); + CACHE1_elog(LOG, "SearchCatCache: found tuple"); ct->ct_magic = CT_MAGIC; ct->my_cache = cache; @@ -1112,7 +1112,7 @@ SearchCatCache(CatCache *cache, if (oldct->refcount == 0) { - CACHE2_elog(DEBUG, "SearchCatCache(%s): Overflow, LRU removal", + CACHE2_elog(LOG, "SearchCatCache(%s): Overflow, LRU removal", cache->cc_relname); CatCacheRemoveCTup(oldct->my_cache, oldct); break; @@ -1120,9 +1120,9 @@ SearchCatCache(CatCache *cache, } } - CACHE4_elog(DEBUG, "SearchCatCache(%s): Contains %d/%d tuples", + CACHE4_elog(LOG, "SearchCatCache(%s): Contains %d/%d tuples", cache->cc_relname, cache->cc_ntup, CacheHdr->ch_ntup); - CACHE3_elog(DEBUG, "SearchCatCache(%s): put in bucket %d", + CACHE3_elog(LOG, "SearchCatCache(%s): put in bucket %d", cache->cc_relname, hash); return &ct->tuple; @@ -1194,7 +1194,7 @@ PrepareToInvalidateCacheTuple(Relation relation, { CatCache *ccp; - CACHE1_elog(DEBUG, "PrepareToInvalidateCacheTuple: called"); + CACHE1_elog(LOG, "PrepareToInvalidateCacheTuple: called"); /* * sanity checks diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 8af7072334d..d466a48d2d7 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.91 2001/11/05 17:46:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.92 2002/03/02 21:39:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,6 +38,16 @@ #include "mb/pg_wchar.h" #endif +#define DEFAULT_SERVER_MIN_MESSAGES_STR "notice" +int server_min_messages; +char *server_min_messages_str = NULL; +const char server_min_messages_str_default[] = DEFAULT_SERVER_MIN_MESSAGES_STR; + +#define DEFAULT_CLIENT_MIN_MESSAGES_STR "info" +int client_min_messages; +char *client_min_messages_str = NULL; +const char client_min_messages_str_default[] = DEFAULT_CLIENT_MIN_MESSAGES_STR; + #ifdef ENABLE_SYSLOG /* * 0 = only stdout/stderr @@ -109,7 +119,7 @@ elog(int lev, const char *fmt,...) * Note that we use malloc() not palloc() because we want to retain * control if we run out of memory. palloc() would recursively call * elog(ERROR), which would be all right except if we are working on a - * FATAL or REALLYFATAL error. We'd lose track of the fatal condition + * FATAL or PANIC error. We'd lose track of the fatal condition * and report a mere ERROR to outer loop, which would be a Bad Thing. * So, we substitute an appropriate message in-place, without * downgrading the level if it's above ERROR. @@ -127,10 +137,47 @@ elog(int lev, const char *fmt,...) const char *cp; char *bp; size_t space_needed; + bool output_to_server = false; + bool output_to_client = false; /* size of the prefix needed for timestamp and pid, if enabled */ size_t timestamp_size; + /* Check for old elog calls. Codes were renumbered in 7.3. 2002-02-24 */ + if (lev < DEBUG5) + elog(FATAL, "Pre-7.3 object file made an elog() call. Recompile."); + + if (Use_syslog <= 1 || whereToSendOutput == Debug) + { + if (lev == LOG) + { + if (server_min_messages == LOG) + output_to_server = true; + else if (server_min_messages < FATAL) + output_to_server = true; + } + /* lev != LOG */ + else + { + if (server_min_messages == LOG) + { + if (lev >= FATAL) + output_to_server = true; + } + /* Neither is LOG */ + else if (lev >= server_min_messages) + output_to_server = true; + } + } + + if (lev >= client_min_messages && whereToSendOutput == Remote) + output_to_client = true; + + /* optimization to prevent work for messages that would never be output */ + if (lev < ERROR && Use_syslog < 1 && + output_to_server == false && output_to_client == false) + return; + /* Save error str before calling any function that might change errno */ errorstr = useful_strerror(errno); @@ -142,13 +189,13 @@ elog(int lev, const char *fmt,...) lev = FATAL; /* - * If we are inside a critical section, all errors become REALLYFATAL + * If we are inside a critical section, all errors become PANIC * errors. See miscadmin.h. */ if (lev == ERROR || lev == FATAL) { if (CritSectionCount > 0) - lev = REALLYFATAL; + lev = PANIC; } prefix = elog_message_prefix(lev); @@ -167,12 +214,15 @@ elog(int lev, const char *fmt,...) * vsnprintf won't know what to do with %m). To keep space * calculation simple, we only allow one %m. */ - space_needed = timestamp_size + strlen(prefix) - + strlen(fmt) + strlen(errorstr) + 1; + space_needed = timestamp_size + strlen(prefix) + + strlen(fmt) + strlen(errorstr) + 1; if (copy_lineno) { - /* translator: This string will be truncated at 31 characters. */ + /* + * Prints the failure line of the COPY. Wow, what a hack! bjm + * Translators: Error message will be truncated at 31 characters. + */ snprintf(copylineno_buf, 32, gettext("copy: line %d, "), copy_lineno); space_needed += strlen(copylineno_buf); } @@ -184,7 +234,7 @@ elog(int lev, const char *fmt,...) { /* We're up against it, convert to out-of-memory error */ fmt_buf = fmt_fixedbuf; - if (lev != FATAL && lev != REALLYFATAL) + if (lev != FATAL && lev != PANIC) { lev = ERROR; prefix = elog_message_prefix(lev); @@ -213,7 +263,7 @@ elog(int lev, const char *fmt,...) if (copy_lineno) { strcat(fmt_buf, copylineno_buf); - if (lev == ERROR || lev == FATAL || lev == REALLYFATAL) + if (lev == ERROR || lev == FATAL || lev == PANIC) copy_lineno = 0; } @@ -281,7 +331,7 @@ elog(int lev, const char *fmt,...) { /* We're up against it, convert to out-of-memory error */ msg_buf = msg_fixedbuf; - if (lev != FATAL && lev != REALLYFATAL) + if (lev != FATAL && lev != PANIC) { lev = ERROR; prefix = elog_message_prefix(lev); @@ -309,9 +359,17 @@ elog(int lev, const char *fmt,...) switch (lev) { - case DEBUG: + case DEBUG1: + case DEBUG2: + case DEBUG3: + case DEBUG4: + case DEBUG5: syslog_level = LOG_DEBUG; break; + case LOG: + case INFO: + syslog_level = LOG_INFO; + break; case NOTICE: syslog_level = LOG_NOTICE; break; @@ -321,7 +379,7 @@ elog(int lev, const char *fmt,...) case FATAL: syslog_level = LOG_ERR; break; - case REALLYFATAL: + case PANIC: default: syslog_level = LOG_CRIT; break; @@ -334,11 +392,12 @@ elog(int lev, const char *fmt,...) /* syslog doesn't want a trailing newline, but other destinations do */ strcat(msg_buf, "\n"); - /* write to terminal */ - if (Use_syslog <= 1 || whereToSendOutput == Debug) + /* Write to server logs or server terminal */ + if (output_to_server) write(2, msg_buf, strlen(msg_buf)); - if (lev > DEBUG && whereToSendOutput == Remote) + /* Should we output to the client too? */ + if (output_to_client) { /* Send IPC message to the front-end program */ MemoryContext oldcxt; @@ -351,7 +410,7 @@ elog(int lev, const char *fmt,...) */ oldcxt = MemoryContextSwitchTo(ErrorContext); - if (lev == NOTICE) + if (lev <= NOTICE) /* exclude the timestamp from msg sent to frontend */ send_notice_to_frontend(msg_buf + timestamp_size); else @@ -414,7 +473,7 @@ elog(int lev, const char *fmt,...) * Guard against infinite loop from elog() during error recovery. */ if (InError) - elog(REALLYFATAL, "elog: error during error recovery, giving up!"); + elog(PANIC, "elog: error during error recovery, giving up!"); InError = true; /* @@ -423,7 +482,7 @@ elog(int lev, const char *fmt,...) siglongjmp(Warn_restart, 1); } - if (lev == FATAL || lev == REALLYFATAL) + if (lev == FATAL || lev == PANIC) { /* * Serious crash time. Postmaster will observe nonzero process @@ -673,10 +732,10 @@ send_message_to_frontend(int type, const char *msg) { StringInfoData buf; - AssertArg(type == NOTICE || type == ERROR); + AssertArg(type <= ERROR); pq_beginmessage(&buf); - pq_sendbyte(&buf, type == NOTICE ? 'N' : 'E'); + pq_sendbyte(&buf, type != ERROR ? 'N' : 'E'); /* N is INFO or NOTICE */ pq_sendstring(&buf, msg); pq_endmessage(&buf); @@ -731,9 +790,19 @@ elog_message_prefix(int lev) switch (lev) { - case DEBUG: + case DEBUG1: + case DEBUG2: + case DEBUG3: + case DEBUG4: + case DEBUG5: prefix = gettext("DEBUG: "); break; + case LOG: + prefix = gettext("LOG: "); + break; + case INFO: + prefix = gettext("INFO: "); + break; case NOTICE: prefix = gettext("NOTICE: "); break; @@ -741,13 +810,112 @@ elog_message_prefix(int lev) prefix = gettext("ERROR: "); break; case FATAL: - prefix = gettext("FATAL 1: "); + prefix = gettext("FATAL: "); break; - case REALLYFATAL: - prefix = gettext("FATAL 2: "); + case PANIC: + prefix = gettext("PANIC: "); break; } Assert(prefix != NULL); return prefix; } + + +/* + * GUC support routines + */ + +bool +check_server_min_messages(const char *lev) +{ + if (strcasecmp(lev, "debug") == 0 || + strcasecmp(lev, "debug1") == 0 || + strcasecmp(lev, "debug2") == 0 || + strcasecmp(lev, "debub3") == 0 || + strcasecmp(lev, "debug4") == 0 || + strcasecmp(lev, "debug5") == 0 || + strcasecmp(lev, "log") == 0 || + strcasecmp(lev, "info") == 0 || + strcasecmp(lev, "notice") == 0 || + strcasecmp(lev, "error") == 0 || + strcasecmp(lev, "fatal") == 0 || + strcasecmp(lev, "panic") == 0) + return true; + return false; +} + +void +assign_server_min_messages(const char *lev) +{ + if (strcasecmp(lev, "debug1") == 0) + server_min_messages = DEBUG1; + else if (strcasecmp(lev, "debug2") == 0) + server_min_messages = DEBUG2; + else if (strcasecmp(lev, "debug3") == 0) + server_min_messages = DEBUG3; + else if (strcasecmp(lev, "debug4") == 0) + server_min_messages = DEBUG4; + else if (strcasecmp(lev, "debug5") == 0) + server_min_messages = DEBUG5; + else if (strcasecmp(lev, "log") == 0) + server_min_messages = LOG; + else if (strcasecmp(lev, "info") == 0) + server_min_messages = INFO; + else if (strcasecmp(lev, "notice") == 0) + server_min_messages = NOTICE; + else if (strcasecmp(lev, "error") == 0) + server_min_messages = ERROR; + else if (strcasecmp(lev, "fatal") == 0) + server_min_messages = FATAL; + else if (strcasecmp(lev, "panic") == 0) + server_min_messages = PANIC; + else + /* Can't get here unless guc.c screwed up */ + elog(ERROR, "bogus server_min_messages %s", lev); +} + +bool +check_client_min_messages(const char *lev) +{ + if (strcasecmp(lev, "debug") == 0 || + strcasecmp(lev, "debug1") == 0 || + strcasecmp(lev, "debug2") == 0 || + strcasecmp(lev, "debug3") == 0 || + strcasecmp(lev, "debug4") == 0 || + strcasecmp(lev, "debug5") == 0 || + strcasecmp(lev, "log") == 0 || + strcasecmp(lev, "info") == 0 || + strcasecmp(lev, "notice") == 0 || + strcasecmp(lev, "error") == 0) + return true; + return false; +} + +void +assign_client_min_messages(const char *lev) +{ + if (strcasecmp(lev, "debug1") == 0) + client_min_messages = DEBUG1; + else if (strcasecmp(lev, "debug2") == 0) + client_min_messages = DEBUG2; + else if (strcasecmp(lev, "debug3") == 0) + client_min_messages = DEBUG3; + else if (strcasecmp(lev, "debug4") == 0) + client_min_messages = DEBUG4; + else if (strcasecmp(lev, "debug5") == 0) + client_min_messages = DEBUG5; + else if (strcasecmp(lev, "log") == 0) + client_min_messages = LOG; + else if (strcasecmp(lev, "info") == 0) + client_min_messages = INFO; + else if (strcasecmp(lev, "notice") == 0) + client_min_messages = NOTICE; + else if (strcasecmp(lev, "error") == 0) + client_min_messages = ERROR; + else + /* Can't get here unless guc.c screwed up */ + elog(ERROR, "bogus client_min_messages %s", lev); +} + + diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 1a1633cc570..c1e44f7b2f4 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.54 2001/10/25 05:49:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.55 2002/03/02 21:39:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -399,8 +399,7 @@ find_in_dynamic_libpath(const char *basename) sprintf(full, "%s/%s", mangled, basename); pfree(mangled); - if (DebugLvl > 1) - elog(DEBUG, "find_in_dynamic_libpath: trying %s", full); + elog(DEBUG2, "find_in_dynamic_libpath: trying %s", full); if (file_exists(full)) return full; diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index 904b32ac29a..7fb811e6794 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.40 2001/10/28 06:25:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.41 2002/03/02 21:39:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -933,7 +933,7 @@ hash_corrupted(HTAB *hashp) * systemwide restart. Otherwise, just shut down this one backend. */ if (hashp->isshared) - elog(STOP, "Hash table '%s' corrupted", hashp->tabname); + elog(PANIC, "Hash table '%s' corrupted", hashp->tabname); else elog(FATAL, "Hash table '%s' corrupted", hashp->tabname); } diff --git a/src/backend/utils/init/findbe.c b/src/backend/utils/init/findbe.c index 47f7febd86d..8093107f445 100644 --- a/src/backend/utils/init/findbe.c +++ b/src/backend/utils/init/findbe.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.26 2002/02/08 16:30:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.27 2002/03/02 21:39:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,17 +61,13 @@ ValidateBinary(char *path) */ if (stat(path, &buf) < 0) { - if (DebugLvl > 1) - fprintf(stderr, "ValidateBinary: can't stat \"%s\"\n", - path); + elog(DEBUG2, "ValidateBinary: can't stat \"%s\"", path); return -1; } if ((buf.st_mode & S_IFMT) != S_IFREG) { - if (DebugLvl > 1) - fprintf(stderr, "ValidateBinary: \"%s\" is not a regular file\n", - path); + elog(DEBUG2, "ValidateBinary: \"%s\" is not a regular file", path); return -1; } @@ -92,9 +88,8 @@ ValidateBinary(char *path) { is_r = buf.st_mode & S_IRUSR; is_x = buf.st_mode & S_IXUSR; - if (DebugLvl > 1 && !(is_r && is_x)) - fprintf(stderr, "ValidateBinary: \"%s\" is not user read/execute\n", - path); + if (!(is_r && is_x)) + elog(DEBUG2, "ValidateBinary: \"%s\" is not user read/execute", path); return is_x ? (is_r ? 0 : -2) : -1; } pwp = getpwuid(euid); @@ -119,17 +114,17 @@ ValidateBinary(char *path) { is_r = buf.st_mode & S_IRGRP; is_x = buf.st_mode & S_IXGRP; - if (DebugLvl > 1 && !(is_r && is_x)) - fprintf(stderr, "ValidateBinary: \"%s\" is not group read/execute\n", - path); + if (!(is_r && is_x)) + elog(DEBUG2, "ValidateBinary: \"%s\" is not group read/execute", + path); return is_x ? (is_r ? 0 : -2) : -1; } } is_r = buf.st_mode & S_IROTH; is_x = buf.st_mode & S_IXOTH; - if (DebugLvl > 1 && !(is_r && is_x)) - fprintf(stderr, "ValidateBinary: \"%s\" is not other read/execute\n", - path); + if (!(is_r && is_x)) + elog(DEBUG2, "ValidateBinary: \"%s\" is not other read/execute", + path); return is_x ? (is_r ? 0 : -2) : -1; } @@ -177,9 +172,7 @@ FindExec(char *full_path, const char *argv0, const char *binary_name) if (ValidateBinary(buf) == 0) { strncpy(full_path, buf, MAXPGPATH); - if (DebugLvl) - fprintf(stderr, "FindExec: found \"%s\" using argv[0]\n", - full_path); + elog(DEBUG1, "FindExec: found \"%s\" using argv[0]", full_path); return 0; } fprintf(stderr, "FindExec: invalid binary \"%s\"\n", @@ -193,8 +186,7 @@ FindExec(char *full_path, const char *argv0, const char *binary_name) */ if ((p = getenv("PATH")) && *p) { - if (DebugLvl) - fprintf(stderr, "FindExec: searching PATH ...\n"); + elog(DEBUG1, "FindExec: searching PATH ..."); path = strdup(p); /* make a modifiable copy */ for (startp = path, endp = strchr(path, ':'); startp && *startp; @@ -215,9 +207,8 @@ FindExec(char *full_path, const char *argv0, const char *binary_name) { case 0: /* found ok */ strncpy(full_path, buf, MAXPGPATH); - if (DebugLvl) - fprintf(stderr, "FindExec: found \"%s\" using PATH\n", - full_path); + elog(DEBUG1, "FindExec: found \"%s\" using PATH", + full_path); free(path); return 0; case -1: /* wasn't even a candidate, keep looking */ diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index ec6235aba49..4572a8f05e0 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.62 2001/10/25 05:49:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.63 2002/03/02 21:39:33 momjian Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -69,8 +69,6 @@ Oid MyDatabaseId = InvalidOid; bool IsUnderPostmaster = false; -int DebugLvl = 0; - int DateStyle = USE_ISO_DATES; bool EuroDates = false; bool HasCTZSet = false; diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 0ccbe753d06..5019757832e 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.83 2002/03/01 22:45:15 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.84 2002/03/02 21:39:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -817,13 +817,13 @@ RecordSharedMemoryInLockFile(IpcMemoryKey shmKey, IpcMemoryId shmId) fd = open(directoryLockFile, O_RDWR | PG_BINARY, 0); if (fd < 0) { - elog(DEBUG, "Failed to rewrite %s: %m", directoryLockFile); + elog(LOG, "Failed to rewrite %s: %m", directoryLockFile); return; } len = read(fd, buffer, sizeof(buffer) - 100); if (len <= 0) { - elog(DEBUG, "Failed to read %s: %m", directoryLockFile); + elog(LOG, "Failed to read %s: %m", directoryLockFile); close(fd); return; } @@ -836,7 +836,7 @@ RecordSharedMemoryInLockFile(IpcMemoryKey shmKey, IpcMemoryId shmId) if (ptr == NULL || (ptr = strchr(ptr + 1, '\n')) == NULL) { - elog(DEBUG, "Bogus data in %s", directoryLockFile); + elog(LOG, "Bogus data in %s", directoryLockFile); close(fd); return; } @@ -861,7 +861,7 @@ RecordSharedMemoryInLockFile(IpcMemoryKey shmKey, IpcMemoryId shmId) /* if write didn't set errno, assume problem is no disk space */ if (errno == 0) errno = ENOSPC; - elog(DEBUG, "Failed to write %s: %m", directoryLockFile); + elog(LOG, "Failed to write %s: %m", directoryLockFile); close(fd); return; } diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index b4fffd72529..fe6cf89ac0c 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -4,7 +4,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.10 2002/02/23 01:31:36 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.11 2002/03/02 21:39:33 momjian Exp $ */ %{ @@ -137,7 +137,7 @@ ProcessConfigFile(GucContext context) Assert(context == PGC_POSTMASTER || context == PGC_BACKEND || context == PGC_SIGHUP); Assert(DataDir); - elevel = (context == PGC_SIGHUP) ? DEBUG : ERROR; + elevel = (context == PGC_SIGHUP) ? DEBUG3 : ERROR; /* * Open file diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index f140d871f0c..dc6dedab755 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4,7 +4,7 @@ * Support for grand unified configuration scheme, including SET * command, configuration file, and command line options. * - * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.60 2002/03/01 22:45:16 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.61 2002/03/02 21:39:34 momjian Exp $ * * Copyright 2000 by PostgreSQL Global Development Group * Written by Peter Eisentraut <peter_e@gmx.net>. @@ -39,6 +39,7 @@ #include "utils/array.h" #include "utils/builtins.h" #include "utils/datetime.h" +#include "utils/elog.h" #include "pgstat.h" @@ -432,11 +433,6 @@ static struct config_int 1000, 25, INT_MAX, NULL, NULL }, - { - "debug_level", PGC_USERSET, PGC_S_DEFAULT, &DebugLvl, - 0, 0, 16, NULL, NULL - }, - #ifdef LOCK_DEBUG { "trace_lock_oidmin", PGC_SUSET, PGC_S_DEFAULT, &Trace_lock_oidmin, @@ -557,6 +553,12 @@ static struct config_string ConfigureNamesString[] = { { + "client_min_messages", PGC_USERSET, PGC_S_DEFAULT, &client_min_messages_str, + client_min_messages_str_default, check_client_min_messages, + assign_client_min_messages + }, + + { "default_transaction_isolation", PGC_USERSET, PGC_S_DEFAULT, &default_iso_level_string, "read committed", check_defaultxactisolevel, assign_defaultxactisolevel }, @@ -571,6 +573,12 @@ static struct config_string PG_KRB_SRVTAB, NULL, NULL }, + { + "server_min_messages", PGC_USERSET, PGC_S_DEFAULT, &server_min_messages_str, + server_min_messages_str_default, check_server_min_messages, + assign_server_min_messages + }, + #ifdef ENABLE_SYSLOG { "syslog_facility", PGC_POSTMASTER, PGC_S_DEFAULT, &Syslog_facility, @@ -886,7 +894,7 @@ set_config_option(const char *name, const char *value, bool makeDefault; if (context == PGC_SIGHUP) - elevel = DEBUG; + elevel = DEBUG1; else if (guc_session_init) elevel = NOTICE; else @@ -901,9 +909,8 @@ set_config_option(const char *name, const char *value, if (record->source > source) { - if (DebugLvl > 1) - elog(DEBUG, "setting %s refused because previous source is higher", - name); + elog(DEBUG2, "setting %s refused because previous source is higher", + name); return false; } makeDefault = source < PGC_S_SESSION; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7cb15cd4ae4..5e871457796 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -108,8 +108,15 @@ # -# Debug display +# Message display # + +#server_min_messages = log # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, error, log, fatal, panic +#client_min_messages = info # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # log, info, notice, error #silent_mode = false #log_connections = false |