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 1w2nkK-000cLK-0B for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 10:03:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2nkI-009M1v-2f for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 10:03:22 +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 1w2nkI-009M1n-1e for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 10:03:22 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2nkG-00000000uSj-00n1 for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 10:03:22 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2b04fc8851cso37864635ad.0 for ; Wed, 18 Mar 2026 03:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773828198; cv=none; d=google.com; s=arc-20240605; b=MGdoqsgXybjnWbpPyCWkI8hlyE6Ffkph67kueoB3fhdmg1oFqxbojk1WyZM/m+7Joz 6K6U3bPluNlDeHyiMBXc97GlHQooAd6hbINTOd7wRwW/79JpG+RceSJ8nBpfLUHweIMU ZGQpMKTzP/Pvedh20evUO173xFs8cX+IxBULxe+vD+hBKNZOVAzUvSa/1klI3fgZB/7x unBdPr61VDoVQ0YjiJub6MPEVNsPDg0P7IFtlUqcCnb+2IGHoTZ3kIgrlwzV7K/vQB6/ gActftJ5IXs0zTQ/Vrjv+LJ0hI2cXWt6QArmLAg8uxC6iz1SyxPbt5gQxS8G/v3FpEu0 o52w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=vb8DEZAl/mmCYHCv/tAZhPW5kyvfbmnE5lZRwWmSKYo=; fh=34CLbvCxDrDYcpQOJkngt+X4xDFXPY5i7IvlsIHOqW0=; b=J0gVfNokbz14qnsHb6TG8VHyqFXJ0Fl3yORbzeqLO7/dcbO7Iv+jOR29EZ4YvFPca4 jfjjQMPIdEbCJnwKSvcdcHjM/FOMPaYeagV2vFCrJj1CLorpHN32aRk4SfPx3uXW2EUX +K3j1RW6beGdl0rSnx3VUYqeUhnF2QFcvgDmY2dMMhAVIRNhN/KWglzwfHaWwQE7iTrb jqU9hEDXqN0wc83sI4J+7y0NmsUTgRoLkA5Nn70+n3xo6WZWW0KO3htp/9Nyar9FhVbU tcs6ubgtdpYw+3kvtDa4WQ81tdMq3Afo1J1AvDcdMkdBy2T4765ELmuOYn5+gCavEQaY TLcw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773828198; x=1774432998; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vb8DEZAl/mmCYHCv/tAZhPW5kyvfbmnE5lZRwWmSKYo=; b=IOnxqmJoaep5l0WW3H13IXrD4hriqrnNCKWwmX4soEeX+Dw7naQBthplLhhMONkxX+ 3N9JGD3vF6JMJ0OPyZ5p3rCwRrV6ZlNFEJO4S+aQG4/r7kGRA9IZkcKymxfWCFZFnwTV Mlpy1Pg9be0p5oY1sdbHkYHTOWsJyVEXESCwyDfjGnzRqRAAfPjASgnvV7QDESrP1alP 0MzQUMAlmbr988BzstRbDGTjmeWsDqkVzOyYutA3F4mdYR3VQE2jnCDVYwgwFkg0vOHD HEcdKnPJrtrdR1EkF1OvDt1lyjXih1GDbAK9J8Ms0QasxaHDPhaW1pwTYvJ+42Lxa7vv 4m1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773828198; x=1774432998; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vb8DEZAl/mmCYHCv/tAZhPW5kyvfbmnE5lZRwWmSKYo=; b=Bp8hS/ZMljMEKTNiDrEEHfFNT3scTMOkD23lBaWuS/BiEl8AUW2++u2iXrUFGbE4qy kOsyewuD+QpS3aMHmRJGknIm4GikDdCdH51YMnCmoywJ7ZRaK9XmQ+9azD9kCrxpjjmQ 0243Y8fpmbjzEhGOi0JkNJpjTGoAZzy2YEaiZHvl1Y/EG0cOCogz7z1IwCCayVfw7ddL tb9kB3Uk53jwo/pL1pXdMSeAiesHgMCQjW2jJ8tSb0TTjVbdBATh1ST+YOrBlcVmsDv2 A6UURH7jQFkSpMc4wL911YSz2w24CwpjI0yQQvtLAw7/nit3h5TidjrI/7XoY/56EG7Z jMAA== X-Forwarded-Encrypted: i=1; AJvYcCUXjaOkcWaHngjPgWCZVkO8PvAHd6wmscWh+afSOd9Z93itJE/kja0T7qlabDQEpflyQhnzGffOyPs8LarE@lists.postgresql.org X-Gm-Message-State: AOJu0YyBKuWdZ8b4lv+M97Ko9UTF6TUEPXF3Fw7P57tKQKNzbxZkeBXQ ooTpbKC69dB1Oi8ExIdL3jCZvUzkl7yDZ++sL2M8dkUlbgr6A4cXEPBdUgWzcS3ig0Ld2XJ7O3r dnpZw3dTUt8oPE42Hoj3VM1KXK5EBjR4= X-Gm-Gg: ATEYQzxKlsTD7rmae2cHz4fP8PyCDY76X56M4zbHkxbhn/Kc0gu/D0ekbj7vZ7l5qYk +RePDXz1a/V61ZVxBE9EUjC3LTJQ8g9cVlI8Fi8ITNeo2L4sT3RoLMk0SnaJuhcsaKHgttDfkJv LAjOwe2dF9V5K3FmaI6ScbAGQEnO88OUHHDV7pRY/H8+5Q9wZWss49tiLPdQKrnKcDiEkaa0KN8 7cIGyImYM+t2SXyzxOdHIr8GTACc34x4wcd8AF8Q0cyJf0ZM7p6eIGBe917NX91zpgjx5+3GhqM PL4CRHuaSK9wYAVBLYIcrt/C8n49lw0vd6ikx3+3NMDY03gXHj/dRCGlN5yiAHtq X-Received: by 2002:a17:903:2947:b0:2b0:4554:9c24 with SMTP id d9443c01a7336-2b06e3cd0d4mr18720125ad.32.1773828198022; Wed, 18 Mar 2026 03:03:18 -0700 (PDT) MIME-Version: 1.0 References: <48261e54-c4f1-4bde-a4a9-4f3698a6b380@app.fastmail.com> In-Reply-To: From: shveta malik Date: Wed, 18 Mar 2026 15:33:06 +0530 X-Gm-Features: AaiRm51sEGANDOHjU2Pljfvdr_VjIeDLob9lg7yQjFveLRtMm47TAJi8Tk-Cg_Q Message-ID: Subject: Re: [Proposal] Adding Log File Capability to pg_createsubscriber To: =?UTF-8?B?S3Vyb2RhLCBIYXlhdG8v6buS55SwIOmavOS6ug==?= Cc: Gyan Sreejith , Shlok Kyal , vignesh C , Amit Kapila , Euler Taveira , "pgsql-hackers@lists.postgresql.org" , Peter Smith , shveta malik Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 18, 2026 at 11:43=E2=80=AFAM Kuroda, Hayato/=E9=BB=92=E7=94=B0 = =E9=9A=BC=E4=BA=BA wrote: > > Dear Gyan, > > Thanks for updating. Not sure you have addressed my comments as well, > but I reviewed again. > > 01. > ``` > +#undef pg_log_warning > +#define pg_log_warning(...) \ > + if (internal_log_file_fp !=3D NULL) \ > + internal_log_file_write(PG_LOG_WARNING, __VA_ARGS__); \ > + pg_log_generic(PG_LOG_WARNING, PG_LOG_PRIMARY, __VA_ARGS__) > ``` > > IIUC it's more common that to have do {...} while if the marco function h= as > several lines. > > 02. > ``` > +#undef pg_log_info > +#define pg_log_info(...) do { \ > + if (internal_log_file_fp !=3D NULL) \ > + internal_log_file_write(PG_LOG_INFO, __VA_ARGS__); \ > + else \ > + pg_log_generic(PG_LOG_INFO, PG_LOG_PRIMARY, __VA_ARGS__);= \ > +} while(0) > ``` > > Missing update? > > 03. > > I think pg_log_error faimily should be also output on the file, but it mi= sses. > > 04. > ``` > +static void > +make_dir(const char *dir) > ``` > > I think this is not needed, we can follow the approach done on the pg_upg= rade. > The message "directory %s created" may be removed, but I think it's ok. > > 05. > ``` > + /* Build timestamp directory path */ > + len =3D snprintf(timestamp_dir, MAXPGPATH, "%s/%s", log_dir, time= stamp); > + > + if (len >=3D MAXPGPATH) > + pg_fatal("directory path for log files, %s/%s, is too lon= g", > + log_dir, timestamp); > ``` > > These checks should be done before creating the base directory. > > 06. > ``` > +static char *log_timestamp =3D NULL; /* Timestamp to be used in all = log file > + = * names */ > ``` > > I feel it's more efficient to directly have the directory where log exist= s. > > 07. > ``` > + if (opt.log_dir !=3D NULL) > + { > + char *internal_log_file; > + > + make_output_dirs(opt.log_dir); > + internal_log_file =3D psprintf("%s/%s/%s.log", opt.log_di= r, log_timestamp, > + = INTERNAL_LOG_FILE_NAME); > + > + if ((internal_log_file_fp =3D logfile_open(internal_log_f= ile, "a")) =3D=3D NULL) > + pg_fatal("could not open log file \"%s\": %m", in= ternal_log_file); > + } > ``` > > I still think it can be put bit later; after validating simple messages. > How about others? +1, otherwise it will simply create a directory and error out after that if the command is wrong. We can avoid creating a directory. Patch has a compilation issue, logfile_open() needs a second argument in ma= in(). If we fix that, it gives a segmentation fault in make_output_dirs() as logdir is not allocated, earlier it was an array, now a NULL pointer. Kuroda-san is going to post a new patch soon. thanks Shveta