Commit Graph

43 Commits

Author SHA1 Message Date
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
Peter Eisentraut 917a68f010 Translation updates
Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: 3a5a71cccad5c68e01008e9e3a4f06930197a05e
2018-05-21 12:29:52 -04:00
Peter Eisentraut 82d24bab75 Translation updates
Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: 398beeef4921df0956f917becd7b5669d2a8a5c4
2017-05-15 12:19:54 -04:00
Peter Eisentraut bf5bb2e85b Move fsync routines of initdb into src/common/
The intention is to used those in other utilities such as pg_basebackup
and pg_receivexlog.

From: Michael Paquier <michael.paquier@gmail.com>
2016-09-29 12:00:00 -04:00
Peter Eisentraut 48aaba4acf Translation updates
Source-Git-URL: git://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: 17bf3e8564abf600274789fcc90e72532d5e7c05
2016-05-09 10:04:41 -04:00
Peter Eisentraut 382b479ab7 Add new files to nls.mk 2015-05-17 22:55:17 -04:00
Peter Eisentraut ee3bec5e22 Translation updates 2014-12-15 00:25:35 -05:00
Peter Eisentraut f9ddcf7543 Add missing source files to nls.mk
These are files under common/ that have been moved around.  Updating
these manually is not satisfactory, but it's the only solution at the
moment.
2014-07-15 10:10:42 -04:00
Peter Eisentraut 2e6bc4b806 Move rmtree() from libpgport to libpgcommon
It requires pgfnames() from libpgcommon.
2013-10-19 10:20:51 -04:00
Peter Eisentraut ba7c5975ad Move pgfnames() from libpgport to libpgcommon
It requires pstrdup() from libpgcommon.
2013-10-18 21:28:15 -04:00
Peter Eisentraut f39418e9b3 Switch dependency order of libpgcommon and libpgport
Continuing 63f32f3416, libpgcommon should
depend on libpgport, but not vice versa.  But wait_result_to_str() in
wait_error.c depends on pstrdup() in libpgcommon.  So move exec.c and
wait_error.c from libpgport to libpgcommon.  Also switch the link order
in the place that's actually used by the failing ecpg builds.

The function declarations have been left in port.h for now.  That should
perhaps be separated sometime.
2013-10-17 22:02:35 -04:00
Peter Eisentraut 6a007fa1eb Translation updates 2013-09-02 02:43:18 -04:00
Peter Eisentraut 539ecc9241 Translation updates 2013-05-05 22:34:23 -04:00
Peter Eisentraut 9795113916 Add fe_memutils.c to nls.mk where used 2013-03-06 23:45:16 -05:00
Peter Eisentraut f11af2bcab Adjust nls.mk for split out of wait_error.c 2013-03-06 20:26:14 -05:00
Peter Eisentraut 194b5ea3d0 Add new files to NLS file lists
Some of these are newly added, some are older and were forgotten, some
don't contain any translatable strings right now but look like they
could in the future.
2012-03-30 20:46:23 +03:00
Peter Eisentraut c6ef139376 Make _ be automatically included in GETTEXT_TRIGGERS
Since it's globally defined in c.h, it should be treated as a gettext
trigger everywhere.
2011-06-26 23:05:30 +03:00
Peter Eisentraut 1b11e239ca Replace := by = in nls.mk files
It currently doesn't make a difference, but it's inconsistent with
most other usage, and it might interfere with a future patch, so I'll
change it all in a separate commit.

Also, replace tabs with spaces for alignment.
2011-06-26 20:08:38 +03:00
Peter Eisentraut 74b1d29dd1 Translation updates for 9.1beta2 2011-06-09 23:02:48 +03:00
Magnus Hagander 9f2e211386 Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Peter Eisentraut f1ac08daee Translation update 2010-05-13 15:56:43 +00:00
Peter Eisentraut ef8df75e67 Translations update for 8.5alpha2 2009-10-20 18:23:27 +00:00
Peter Eisentraut a6667d96c5 Translation updates for 8.4 release.
File that are translated less than 80% have been removed, as per new
translation team policy.
2009-06-26 19:33:52 +00:00
Peter Eisentraut 80a836cab4 Translation updates for 8.4 beta 2009-04-09 19:38:53 +00:00
Peter Eisentraut 8a8bcb447a Translation updates 2007-10-27 00:13:43 +00:00
Peter Eisentraut 84620860d9 New translations 2005-01-09 17:38:19 +00:00
Peter Eisentraut 6ad835f55f New translations 2004-12-15 17:50:20 +00:00
Peter Eisentraut 99b735cc03 Work around lack of NLS support in libpgport by making those components
who use it scan the relevant source files for their own catalog.  It
creates a bit of duplicate work for translators, but it gets the job done
for now.
2004-11-27 22:44:15 +00:00
Peter Eisentraut 8a1821ab5b Translation update 2004-11-16 22:58:44 +00:00
Peter Eisentraut c22b4fa386 New translation 2004-11-07 23:38:19 +00:00
Peter Eisentraut ad6a6170e5 New translations 2004-09-27 20:21:24 +00:00
Peter Eisentraut 95c034e311 Translation updates 2004-09-13 12:35:18 +00:00
Peter Eisentraut 77697dcaa3 New translations 2004-09-13 12:20:24 +00:00
Peter Eisentraut f781ed4ed8 Translation updates 2004-08-10 19:06:21 +00:00
Peter Eisentraut 630bfcd10c Translation updates 2004-08-02 15:17:21 +00:00
Peter Eisentraut f82d99be7e Translation updates 2004-07-30 05:28:53 +00:00
Peter Eisentraut 0ee0e73c9b Translation updates 2004-07-25 12:00:07 +00:00
Peter Eisentraut fc43abaccf Translation updates 2004-04-05 09:13:43 +00:00
Dennis Bjorklund 15a5440dc5 Translation updates 2004-01-10 09:09:40 +00:00
Peter Eisentraut 3a613816a0 New translation 2003-12-11 22:03:05 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
Peter Eisentraut dc69cc1097 New translation 2003-11-25 19:19:21 +00:00
Peter Eisentraut e2d9066527 Add NLS support. 2003-11-23 21:41:30 +00:00