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 1vnZQh-008xLK-11 for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Feb 2026 09:44:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vnZQg-00AEoK-0h for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Feb 2026 09:44:10 +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 1vnZQf-00AEoC-2f for pgsql-hackers@lists.postgresql.org; Wed, 04 Feb 2026 09:44:09 +0000 Received: from mail-yx1-xb131.google.com ([2607:f8b0:4864:20::b131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vnZQd-000000010IR-0GKW for pgsql-hackers@lists.postgresql.org; Wed, 04 Feb 2026 09:44:09 +0000 Received: by mail-yx1-xb131.google.com with SMTP id 956f58d0204a3-649bff225d4so3139071d50.2 for ; Wed, 04 Feb 2026 01:44:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770198245; cv=none; d=google.com; s=arc-20240605; b=kjK8w1tdX8mG/9zB9c8hgN8FIClddb4fJ5xOWrYkwfybr3wpKL+MEhmKgwCVVOdksZ cND2GBfwKpl8tf8R91k8bRtgG3vdM69W1UEUDuoM019DsvTwZS26PHp2lxpQj1DfA3b9 mM9/iUqzJ2qaQ9DlJJTgPpOi+IUazviFFYfcLkpFlQyGFiMaIw87ARgrJBxtbtdt52ZW EJYOVmvEbdd6XWdBaSg1pfCENqkizqbHkT2Nly263QqkDpeVVD/IZ4exjvqbcxvRPO2r lVWtbIDW4DZq68UHXL8uwwy/j62WDOOss9rNgHg/NIwi7MwY9avi0ytKd4mN5SXP1DXL l/cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=LZk0IVsgnHpqJEyYDSLQhxfZH6SfgqveB6I8rwDrquk=; fh=Ma5zO9qbNSPZBWee2pSyNEFaR829QmN1czKxpwKqLTk=; b=WKBIbmcR49Cw88rxqaX1o7rpRTlvt3aY6KX+kkGVNTIeKh27vWNlMcLAoQ0tRB0F6F r5o74aageuJBCIfy7+dByXOhXQ6Z7eeiU9FpIe0g6Q908L8eBeve8lGDQo+x3ow8rwXs fRvnUIOgPs153YttQPUeClhNN4au2CMrHkQAbnhJwT0FpEuPNnZbBqUjdLydGaWZUpNo PNIyalVsI6t8K4TC1xtYdksoQb8WQyN4Ib+ljXRI8SxWSTaNjeaxkKR25OI40yDMIB4B l6onEmChPiCDmqJAaHTO0XVhLjTCTCgED2p/NQoXjB+/J16S/lpfLtbl5BF91kI2EFcu +/Jw==; 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=1770198245; x=1770803045; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LZk0IVsgnHpqJEyYDSLQhxfZH6SfgqveB6I8rwDrquk=; b=dIdCJSsaq1vXmcyNG/kP0MkpdaS7lnJ8Dvjyd6ybsIuvS38Bm9LHrOdYbI2nk9EQ2s +/AzFAhd8+GbzGf5k5mxkSi8hQNF2FfvqSJMBLyTTW0+vv+td4ZtjS7tTMduEiWcXkTE Pdzl9qxcrORZCW9CN/S27bpVOQmqIf0JiitL1BNndwUf1o/9sSPpd4BDLrmK7z+wsBO/ ebEe8BwVA+iihejbtZwA/3RYywb2iGORuRQr/SjCbqPG4JiC8hyg6TSXAUYFuiNp48ZY MF4+Hkf/77ZzZ/hZM6doRD7VMVFSjm4eFpIDKbXuNooxsQ7hrp6oH+lA68ONNB2GPH0t ArPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770198245; x=1770803045; h=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=LZk0IVsgnHpqJEyYDSLQhxfZH6SfgqveB6I8rwDrquk=; b=rq44V8d0zNI/OQiF9Zhumsda3wNZq6caQGKVjI+PheojvcAkRrg3tjzjGG6pUtMYPO z4SGOOoWITvGORjlT3gMHWnirFdNBMRC28cROhBkEtAx6dXDsD133Hkh8oTOzFrJCDB1 hPQukJisuAueaqtNqqD7TdmUiuXz5oJhLf9x95psKqzfHaKHP2+sgqPUaB56sx1pKOg3 dMxsEo4IyZbN4qyF78ip/pICo2oyjqMAvnjBtUv0iFqWKHN5B5WBKsrIsBCvDJIbFpdO JMfa4KrzXpxoyb+PYotjf75HfdKgZIXbtwfD/onfH8aHZYxVFW2O7owqDIX3QIHUKgU5 KoZg== X-Forwarded-Encrypted: i=1; AJvYcCVpjP10FLd2dlz5s9ROWqrC53uAKT6a5hyYq7pDtDfzqo0xgogBCRtybZoS06W2ZmAfPVRi4Ld4KRDixSgq@lists.postgresql.org X-Gm-Message-State: AOJu0Yw/LAsEfG7fbClZrRc4ygeKJzWGQmFrPie0fqMFfXcETfEjF3O5 oKS5t40WxDw0uK9JF9qG4uFSmM7QAAUj/eFicbIGz/j+EmZb6qb8myqzWpUqeLyxbuoCciN9OUF 3jmQiv247HEb+PU0s+S4zVskBQwd7IHk= X-Gm-Gg: AZuq6aKfFfDkzdkOKN9yZFsAXvWdbB/jF6GWQpo4OvO6gs5kExZ7wKpX2XGRPHDrJli xJjmTj/9m0Hn7aExeCvH3jSiCWufCoEcuMHRwtZVzrGVP14kIr3Yj5MCwuIqOvumDFIoXurEKJ2 2S/cZepAZi3mESzU8OEIcR8B/Ka0lFjXqOAnlyaVbiWcrNoMiyaV/WyFZdJNSEvVIPUTJmj1ry+ 6rqKLBI+7o3Gb12iv3xHGiefyqfVgxcznviN7EQJly+CTwtpuQhB6vxH9FBf8/oKcAF03rKPQ== X-Received: by 2002:a05:690e:14c2:b0:649:bcf2:b68a with SMTP id 956f58d0204a3-649db4c7cb2mr1848765d50.97.1770198245467; Wed, 04 Feb 2026 01:44:05 -0800 (PST) MIME-Version: 1.0 References: <48261e54-c4f1-4bde-a4a9-4f3698a6b380@app.fastmail.com> In-Reply-To: From: vignesh C Date: Wed, 4 Feb 2026 15:13:53 +0530 X-Gm-Features: AZwV_Qjr1Kt0rmWNgpR33JymvYBHXhR-KebQOjYIwWfBVRa96Wctz-utGIPbS8A Message-ID: Subject: Re: [Proposal] Adding Log File Capability to pg_createsubscriber To: Gyan Sreejith Cc: Amit Kapila , Euler Taveira , "kuroda.hayato@fujitsu.com" , "pgsql-hackers@lists.postgresql.org" , Peter Smith Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2 Feb 2026 at 04:35, Gyan Sreejith wrote: > > Thank you! > > I have made the suggested changes. In addition, I added a wrapper for pg_fatal to write to the file and then do everything that pg_fatal would do. > I have attached the patch. Few comments: 1) Can we change the macro names: INFO -> pg_log_info INFO_HINT -> pg_log_info_hint DEBUG -> pg_log_debug FATAL -> pg_fatal if required do an #undef and call pg_log_generic in the else similar to how it is done in pg_backup_utils.h +#define INFO(...) do{\ + if (internal_log_file_fp != NULL) \ + internal_log_file_write(__VA_ARGS__); \ + else \ + pg_log_info(__VA_ARGS__);\ +} while(0) + +#define INFO_HINT(...) do{\ + if (internal_log_file_fp != NULL) \ + internal_log_file_write(__VA_ARGS__); \ + else \ + pg_log_info_hint(__VA_ARGS__);\ +} while(0) + +#define DEBUG(...) do{\ + if (internal_log_file_fp != NULL) \ + internal_log_file_write(__VA_ARGS__); \ + else \ + pg_log_debug(__VA_ARGS__);\ +} while(0) + +#define FATAL(...) do{\ + if (internal_log_file_fp != NULL) \ + internal_log_file_write(__VA_ARGS__); \ + pg_fatal(__VA_ARGS__); /* call pg_fatal after writing to logs */ \ +} while(0) 2) You can keep the variabled in case 'l' handling to keep the scope accordingly: + char timestamp[128]; + struct timeval tval; + time_t now; 3) Instead of creating a new standby and running with -l option, can you run it with -l for one of the existing tests: +$node_p->backup('backup_3'); + +# Set up node R as a logical replica node +my $node_r = PostgreSQL::Test::Cluster->new('node_r'); +$node_r->init_from_backup($node_p, 'backup_3', has_streaming => 1); +$node_r->append_conf( + 'postgresql.conf', qq[ +primary_conninfo = '$pconnstr dbname=postgres' +hot_standby_feedback = on +]); +$node_r->set_standby_mode(); + +# Test that --logdir works for pg_createsubscriber +command_ok( + [ + 'pg_createsubscriber', + '--verbose', + '--pgdata' => $node_r->data_dir, + '--publisher-server' => $pconnstr, + '--database' => 'postgres', + '--logdir' => $logdir, + ], + 'check for log file creation for pg_createSubscriber'); + +# Check that the log files were created +my @server_log_files = glob "$logdir/pg_createsubscriber_server_*.log"; +is( scalar(@server_log_files), 1, " + pg_createsubscriber_server.log file was created"); +my @internal_log_files = glob "$logdir/pg_createsubscriber_internal_*.log"; +is( scalar(@internal_log_files), 1, " + pg_createsubscriber_internal.log file was created"); Regards, Vignesh