postmaster: Reduce verbosity of environment dump debug message
authorAndres Freund <[email protected]>
Wed, 27 Nov 2024 16:17:23 +0000 (11:17 -0500)
committerAndres Freund <[email protected]>
Wed, 27 Nov 2024 16:17:23 +0000 (11:17 -0500)
Emitting each variable separately is unnecessarily verbose / hard to skim
over. Emit the whole thing in one ereport() to address that.

Also remove program name and function reference from the message. The former
doesn't seem particularly helpful and the latter is provided by the elog.c
infrastructure these days.

Reviewed-by: Heikki Linnakangas <[email protected]>
Reviewed-by: Peter Eisentraut <[email protected]>
Discussion: https://postgr.es/m/leouteo5ozcrux3fepuhtbp6c56tbfd4naxeokidbx7m75cabz@hhw6g4urlowt

src/backend/postmaster/postmaster.c

index 78e66a06ac5874161202fdd14ed76b263ffe3c2e..6376d430870a78ec76dd07297628f2c6572e1f17 100644 (file)
@@ -839,20 +839,20 @@ PostmasterMain(int argc, char *argv[])
 #endif
 
    /* For debugging: display postmaster environment */
+   if (message_level_is_interesting(DEBUG3))
    {
        extern char **environ;
        char      **p;
+       StringInfoData si;
 
-       ereport(DEBUG3,
-               (errmsg_internal("%s: PostmasterMain: initial environment dump:",
-                                progname)));
-       ereport(DEBUG3,
-               (errmsg_internal("-----------------------------------------")));
+       initStringInfo(&si);
+
+       appendStringInfoString(&si, "initial environment dump:");
        for (p = environ; *p; ++p)
-           ereport(DEBUG3,
-                   (errmsg_internal("\t%s", *p)));
-       ereport(DEBUG3,
-               (errmsg_internal("-----------------------------------------")));
+           appendStringInfo(&si, "\n%s", *p);
+
+       ereport(DEBUG3, errmsg_internal("%s", si.data));
+       pfree(si.data);
    }
 
    /*