Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vyA1S-00HV2T-2a for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 14:49:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vyA1R-00HWsS-0d for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 14:49:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vyA1Q-00HWsJ-0h for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2026 14:49:53 +0000 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vyA1M-00000000wyc-2pzs for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2026 14:49:52 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 06B7B7A017A; Thu, 5 Mar 2026 09:49:44 -0500 (EST) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-06.internal (MEProxy); Thu, 05 Mar 2026 09:49:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1772722184; x=1772808584; bh=erP3CswTYH4YIBTDwUZB3FmsO4mGQq7W6k1U5i9SX/g=; b= DvHR+ZPX3adY+DRRGtF8lYz4o6VYvyKi71lGlExOzNoagxHaEizUGBeDvBp8gJNT 06o37zlZDXL4jW9+xnXox4M0BkAbRly/U/bkwxiDBjBaiSZoO84hZ1bG3wRtQZU8 GX9nsDDeto+qChBXBGtcRwi1/G04BhgRywTs4zn8p5gd82uxrW9/1FpGRWHR2xVA rPIPCCznNd7TSSameJ51hnFjpP0IgipeM9dGfmcYvJvUIhSjiUkD5YO6Wyxo4eIy GqXuGjxF40CzKr3LeTO8doe4BW6D5hLX2W4+YxyKBD7o6zkV9Fg6ZLdrNaWgOCdz jpWvnaZPWdg1Xjc+c9iIjg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1772722184; x= 1772808584; bh=erP3CswTYH4YIBTDwUZB3FmsO4mGQq7W6k1U5i9SX/g=; b=m /2mI504OwDMIBjtfKzonvikg1s/zuDA5xB167IJ7Q1h9q4/Z370iQu60nQL6AhJg /vC9cfh0Zw7I1QayTx19G1A2YgUURAFafJxxxjzag9sYx+bXe0baABo6iitpd3Im pTk6IEtod9FjsftJTaF2jeMoiXg0xSQUzs92GJ5X/YEwlqGgPr3ta6nk+WbMonK9 ybW4F/7Zxmo9AoyYUK/mRie13EyEbrabrpaMdk60YTnOyIs0flts3y5FBMCjKsRi OTGZQYUzyUfDrHdg0P3WgvZK9nNeTAv0qCYH68Q0sZ5XulzhJGZI25oTUBp9T/uV QTmuLMBJ8iLX218jhBcXw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvieeiieeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvfevkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfgfhulhgv rhcuvfgrvhgvihhrrgdfuceovghulhgvrhesvghulhgvrhhtohdrtghomheqnecuggftrf grthhtvghrnhepleevgfeileegfffglefgfeefffeghfefvdeftdduvdffieeijeffudel iefhvdevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegvuhhlvghrsegvuhhl vghrthhordgtohhmpdhnsggprhgtphhtthhopeeipdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehkuhhrohgurgdrhhgrhigrthhosehfuhhjihhtshhurdgtohhmpdhrtghp thhtoheprghmihhtrdhkrghpihhlrgduieesghhmrghilhdrtghomhdprhgtphhtthhope hghigrnhdrshhrvggvjhhithhhsehgmhgrihhlrdgtohhmpdhrtghpthhtohepshhmihht hhhpsgdvvdehtdesghhmrghilhdrtghomhdprhgtphhtthhopehvihhgnhgvshhhvdduse hgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishht shdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0c21471d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 86E14182007A; Thu, 5 Mar 2026 09:49:44 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: A8ybDLe7M4Pg Date: Thu, 05 Mar 2026 11:48:57 -0300 From: "Euler Taveira" To: "Gyan Sreejith" , "vignesh C" Cc: "Amit Kapila" , "kuroda.hayato@fujitsu.com" , "pgsql-hackers@lists.postgresql.org" , "Peter Smith" Message-Id: In-Reply-To: References: <48261e54-c4f1-4bde-a4a9-4f3698a6b380@app.fastmail.com> Subject: Re: [Proposal] Adding Log File Capability to pg_createsubscriber Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Feb 24, 2026, at 8:55 PM, Gyan Sreejith wrote: > I have made the changes you suggested and have attached the patch below. > [Avoid top-posting ...] I took another look at this patch. Comments are below: +/* + * Open a new logfile with proper permissions. + * From src/backend/postmaster/syslogger.c + */ +static FILE * +logfile_open(const char *filename, const char *mode) +{ Don't duplicate code. If you are reusing a function, my advice is to move it to src/common. You can always use "ifdef FRONTEND" to use the appropriate log message (elog/ereport vs pg_error, for example). - * XXX this code was extracted from BootStrapXLOG(). + * XXX this code was extracted from BootStrapXpg_log_info(). This is a typo. + case 'l': + { + char timestamp[128]; + struct timeval tval; + time_t now; + struct tm tmbuf; I would expect to have this code in a function. That's the pattern it is using. + strftime(timestamp, sizeof(timestamp), "%Y-%m-%d-%H-%M-%S", localtime_r(&now, &tmbuf)); + /* append microseconds */ + snprintf(timestamp + strlen(timestamp), sizeof(timestamp) - strlen(timestamp), + ".%06u", (unsigned int) (tval.tv_usec)); + log_timestamp = pg_strdup(timestamp); Do we really need microseconds? I would say milliseconds is sufficient. I suggest to remove the dash (-); it is using a different style from existing code (pg_upgrade). + opt.log_dir = pg_strdup(optarg); + canonicalize_path(opt.log_dir); You didn't have a check for long path. It is not a good idea in general. See MAXPGPATH examples. It would be a good idea if the path are restricted to MAXPGPATH length. + if (errno == ENOENT) + { + if (mkdir(opt.log_dir, S_IRWXU) == 0) + pg_log_info("log directory created"); + else if (errno == EACCES) + pg_fatal("permission denied trying to create log directory \"%s\": %m", opt.log_dir); + else + pg_fatal("could not create log directory \"%s\": %m", opt.log_dir); + } + else if (errno == EACCES) + pg_fatal("permission denied trying to access directory \"%s\": %m", opt.log_dir); + else + pg_fatal("could not access directory \"%s\": %m", opt.log_dir); The "permission denied" is redundant here because it will be in %m. Instead, I suggest that you use could not create directory \"%s\": %m The main advantage is that this sentence is already available. It avoids translation effort. +#undef pg_log_info +#define pg_log_info(...) do{\ + if (internal_log_file_fp != NULL) \ + internal_log_file_write(__VA_ARGS__); \ + else \ + pg_log_generic(PG_LOG_INFO,PG_LOG_PRIMARY,__VA_ARGS__);\ +} while(0) I don't like the fact that internal_log_file_fp is not declared before this #define. One of the arguments to have this feature was that pg_createsubscriber mixes the server and tool messages. Couldn't we fix it adding "marks" on the output saying the server log messages starts here and the server log messages ends here? -- Euler Taveira EDB https://www.enterprisedb.com/