Re: pgbench - use pg logging capabilities

Michael Paquier <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.general
Message-ID <[email protected]>
On Wed, Jan 08, 2020 at 03:31:46PM +0100, Peter Eisentraut wrote:
> On 2020-01-08 15:12, Michael Paquier wrote:
>> while syntax_error() has been
>> changed in a more modular way.
> 
> I don't follow what you mean by that.

The first versions of the patch did not change syntax_error(), and the
version committed has switched to use PQExpBufferData there.  I think
that we should just do the same for the debug logs executing the meta
commands.  This way, we get an output consistent with what's printed
out for sending or receiving stuff.  Please see the attached.
--
Michael
pgbench-logs.patch (text/x-diff, 731 B)
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index ee1134aea2..39c1a243d5 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -3297,10 +3297,17 @@ executeMetaCommand(CState *st, instr_time *now)
 
 	if (unlikely(__pg_log_level <= PG_LOG_DEBUG))
 	{
-		fprintf(stderr, "client %d executing \\%s", st->id, argv[0]);
+		PQExpBufferData	buf;
+
+		initPQExpBuffer(&buf);
+
+		printfPQExpBuffer(&buf, "client %d executing \\%s", st->id, argv[0]);
 		for (int i = 1; i < argc; i++)
-			fprintf(stderr, " %s", argv[i]);
-		fprintf(stderr, "\n");
+			appendPQExpBuffer(&buf, " %s", argv[i]);
+
+		pg_log_debug("%s", buf.data);
+
+		termPQExpBuffer(&buf);
 	}
 
 	if (command->meta == META_SLEEP)
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl4WpegACgkQnvQgOdby
QH050A//cWiZ60u5Dr/CZKfbBEzdOImw6FT/Pr15Muj72sXTFKhFxgQwKaXMpmD7
2jYuKnGp54qI0La4egsOH7IAgTRNQKWZCu9SQkfZ2atWhagpkprXrQC6rO4f8ICi
kifUdg3/aO+oAynD6jO4Ly6yZJnzWQWBoCyo7fsX/GKjErfD54I9kIQ7cy3AuI4N
vsIRYnwkocEfX/Gb4j3YyjKebQ8A2W/AYRUWg85NS976reZ1DbSwiCioco8mQ4ly
dueKkMRryItTgdtT+XNDVMzyR4EnaJNBvPB4mETp3UNJ/cNxwq2BHAbaVU8RdM66
cYi3PFqBb2APy49KBDmeJDU92YptH6Z1+pesb51ioeOtI0GH+3PG9j2nSN9Y3tEs
80qfdJndYM6YuS2A8rNiK4oWP1lyiV299X1vnncBJtIK3O9tPlk4H0yZZ8xC43kL
hMH96WrwNuIQAq6Yxz2gyBx6MDOcKBZRyudPH08mP7oQeZVr3r63iQXh+bexsOA0
y2n+m3L9pB+Y3LzAuFFm4DvxuNmlmxM1CYuKNZDbffq9J0ScHE9LhvBf/mUguCW8
OOFLK0epsk2sE0JAZjvCaFEuHznA4tnEn4pI6fMVFP6sA7WLBBu1Z7u4AxK3mu4D
y7/rQJF9NEwRZgOiw2i1kGr71xZpu7zLVDgKp+gP7t6kz6qFGy8=
=lBda
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.