Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfA7N-0001E4-JH for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Jan 2019 21:01:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gfA7K-00005E-Rn for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Jan 2019 21:01:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfA7K-000057-F4 for pgsql-hackers@lists.postgresql.org; Thu, 03 Jan 2019 21:01:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfA7D-0003Bo-3x for pgsql-hackers@postgresql.org; Thu, 03 Jan 2019 21:01:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x03L1EQW006175; Thu, 3 Jan 2019 16:01:14 -0500 From: Tom Lane To: Peter Eisentraut cc: Andres Freund , pgsql-hackers Subject: Re: Unified logging system for command-line programs In-reply-to: References: <6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com> <21141.1546199123@sss.pgh.pa.us> <20181231155557.7mokxwg7fnvoxd4a@alap3.anarazel.de> <841dd9fb-3550-dce0-e9ff-8f64cac9f15d@2ndquadrant.com> <20190103180315.o4gh3id5quh5aebc@alap3.anarazel.de> Comments: In-reply-to Peter Eisentraut message dated "Thu, 03 Jan 2019 19:54:28 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6173.1546549274.1@sss.pgh.pa.us> Date: Thu, 03 Jan 2019 16:01:14 -0500 Message-ID: <6174.1546549274@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut writes: > On 03/01/2019 19:03, Andres Freund wrote: >>> Relatedly, rewriting all the frontend programs to exception style would >>> end up being a 10x project to rewrite everything for no particular >>> benefit. Going from 8 or so APIs to 2 is already an improvement, I >>> think. If someone wants to try going further, it can be considered, but >>> it would be an entirely different project. >> Why would it be 10x the effort, > Because you would have to rewrite all the programs to handle elog(ERROR) > jumping somewhere else. FWIW, this argument has nothing to do with what I was actually proposing. I envisioned that we'd have a wrapper in which non-error ereports() map directly onto what you're calling pg_log_debug, pg_log_warning, etc, while ereport(ERROR) has the effect of writing a message and then calling exit(1). We would use ereport(ERROR) in exactly the places where we're now writing a message and calling exit(1). No change at all in program flow control, but an opportunity to consolidate code in places that are currently doing this sort of thing: #ifndef FRONTEND ereport(ERROR, (errcode_for_file_access(), errmsg("could not open file \"%s\" for reading: %m", ControlFilePath))); #else { fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"), progname, ControlFilePath, strerror(errno)); exit(EXIT_FAILURE); } #endif regards, tom lane