postgresql/src/include
Peter Eisentraut cc8d415117 Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.

Features:

- Program name is automatically prefixed.

- Message string does not end with newline.  This removes a common
  source of inconsistencies and omissions.

- Additionally, a final newline is automatically stripped, simplifying
  use of PQerrorMessage() etc., another common source of mistakes.

- I converted error message strings to use %m where possible.

- As a result of the above several points, more translatable message
  strings can be shared between different components and between
  frontends and backend, without gratuitous punctuation or whitespace
  differences.

- There is support for setting a "log level".  This is not meant to be
  user-facing, but can be used internally to implement debug or
  verbose modes.

- Lazy argument evaluation, so no significant overhead if logging at
  some level is disabled.

- Some color in the messages, similar to gcc and clang.  Set
  PG_COLOR=auto to try it out.  Some colors are predefined, but can be
  customized by setting PG_COLORS.

- Common files (common/, fe_utils/, etc.) can handle logging much more
  simply by just using one API without worrying too much about the
  context of the calling program, requiring callbacks, or having to
  pass "progname" around everywhere.

- Some programs called setvbuf() to make sure that stderr is
  unbuffered, even on Windows.  But not all programs did that.  This
  is now done centrally.

Soft goals:

- Reduces vertical space use and visual complexity of error reporting
  in the source code.

- Encourages more deliberate classification of messages.  For example,
  in some cases it wasn't clear without analyzing the surrounding code
  whether a message was meant as an error or just an info.

- Concepts and terms are vaguely aligned with popular logging
  frameworks such as log4j and Python logging.

This is all just about printing stuff out.  Nothing affects program
flow (e.g., fatal exits).  The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.

I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded.  One significant change is that
pg_rewind used to write all error messages to stdout.  That is now
changed to stderr.

Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 20:01:35 +02:00
..
access tableam: bitmap table scan. 2019-03-31 18:37:57 -07:00
bootstrap Update copyright for 2019 2019-01-02 12:44:25 -05:00
catalog GIN support for @@ and @? jsonpath operators 2019-04-01 18:08:52 +03:00
commands REINDEX CONCURRENTLY 2019-03-29 08:26:33 +01:00
common Unified logging system for command-line programs 2019-04-01 20:01:35 +02:00
datatype Update copyright for 2019 2019-01-02 12:44:25 -05:00
executor Generated columns 2019-03-30 08:15:57 +01:00
fe_utils Unified logging system for command-line programs 2019-04-01 20:01:35 +02:00
foreign Store tuples for EvalPlanQual in slots, rather than as HeapTuples. 2019-03-01 10:37:57 -08:00
jit Renaming for new subscripting mechanism 2019-02-01 12:50:32 -03:00
lib Add IntegerSet, to hold large sets of 64-bit ints efficiently. 2019-03-22 13:21:45 +02:00
libpq Add new clientcert hba option verify-full 2019-03-09 12:19:47 -08:00
mb Update copyright for 2019 2019-01-02 12:44:25 -05:00
nodes tableam: bitmap table scan. 2019-03-31 18:37:57 -07:00
optimizer tableam: Move heap specific logic from estimate_rel_size below tableam. 2019-03-30 19:26:36 -07:00
parser Generated columns 2019-03-30 08:15:57 +01:00
partitioning Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
port Fix previous MinGW fix. 2019-02-16 15:23:02 +00:00
portability Update copyright for 2019 2019-01-02 12:44:25 -05:00
postmaster Convert [autovacuum_]vacuum_cost_delay into floating-point GUCs. 2019-03-10 15:01:39 -04:00
regex Partial implementation of SQL/JSON path language 2019-03-16 12:16:48 +03:00
replication Add walreceiver API to get remote server version 2019-03-15 10:16:26 +01:00
rewrite Update copyright for 2019 2019-01-02 12:44:25 -05:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Fix deserialization of pg_mcv_list values 2019-03-28 20:03:14 +01:00
storage Add basic infrastructure for 64 bit transaction IDs. 2019-03-28 18:12:20 +13:00
tcop Update copyright for 2019 2019-01-02 12:44:25 -05:00
tsearch Update copyright for 2019 2019-01-02 12:44:25 -05:00
utils GIN support for @@ and @? jsonpath operators 2019-04-01 18:08:52 +03:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
c.h Add macro to cast away volatile without allowing changes to underlying type 2019-03-25 09:37:03 +01:00
fmgr.h Change function call information to be variable length. 2019-01-26 14:17:52 -08:00
funcapi.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
getaddrinfo.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
getopt_long.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
miscadmin.h Convert [autovacuum_]vacuum_cost_delay into floating-point GUCs. 2019-03-10 15:01:39 -04:00
pg_config.h.in Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. 2019-02-15 23:22:33 -05:00
pg_config.h.win32 Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. 2019-02-15 23:22:33 -05:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_getopt.h Use our own getopt() on OpenBSD. 2019-01-18 15:06:26 -05:00
pg_trace.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pgstat.h Add progress reporting for CLUSTER and VACUUM FULL. 2019-03-25 10:59:04 -04:00
pgtar.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pgtime.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
port.h Cygwin and Mingw floating-point fixes. 2019-02-16 01:50:16 +00:00
postgres.h Change function call information to be variable length. 2019-01-26 14:17:52 -08:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
rusagestub.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
windowapi.h Update copyright for 2019 2019-01-02 12:44:25 -05:00