diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-04-12 13:25:29 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-04-12 13:25:29 -0400 |
commit | 2c9381840fe2d6d1c3179350493fe5fd3dcf90b5 (patch) | |
tree | a3f2602820c03debd96074c6621ac62a0e3f12a0 /src/common/logging.c | |
parent | d4f109e4a2c028bcd889cc44d84b10fff7d9186b (diff) | |
download | postgresql-2c9381840fe2d6d1c3179350493fe5fd3dcf90b5.tar.gz postgresql-2c9381840fe2d6d1c3179350493fe5fd3dcf90b5.zip |
Remove not-very-useful early checks of __pg_log_level in logging.h.
Enforce __pg_log_level message filtering centrally in logging.c,
instead of relying on the calling macros to do it. This is more
reliable (e.g. it works correctly for direct calls to pg_log_generic)
and it saves a percent or so of total code size because we get rid of
so many duplicate checks of __pg_log_level.
This does mean that argument expressions in a logging macro will be
evaluated even if we end up not printing anything. That seems of
little concern for INFO and higher levels as those messages are printed
by default, and most of our frontend programs don't even offer a way to
turn them off. I left the unlikely() checks in place for DEBUG
messages, though.
Discussion: https://postgr.es/m/3993549.1649449609@sss.pgh.pa.us
Diffstat (limited to 'src/common/logging.c')
-rw-r--r-- | src/common/logging.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/common/logging.c b/src/common/logging.c index 2933cab85c8..0b5bcb1a172 100644 --- a/src/common/logging.c +++ b/src/common/logging.c @@ -228,6 +228,10 @@ pg_log_generic_v(enum pg_log_level level, enum pg_log_part part, Assert(fmt); Assert(fmt[strlen(fmt) - 1] != '\n'); + /* Do nothing if log level is too low. */ + if (level < __pg_log_level) + return; + /* * Flush stdout before output to stderr, to ensure sync even when stdout * is buffered. |