1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-24 08:52:38 +02:00

[Issue #134] use new logging infrastructure introduced in PG12

This commit is contained in:
Grigory Smolkin 2019-10-28 12:12:15 +03:00
parent c7110fdcb3
commit 3d4c2f23e5
3 changed files with 38 additions and 6 deletions

View File

@ -13,11 +13,11 @@ OBJS += src/archive.o src/backup.o src/catalog.o src/checkdb.o src/configure.o s
OBJS += src/pg_crc.o src/datapagemap.o src/receivelog.o src/streamutil.o \
src/xlogreader.o
EXTRA_CLEAN = src/pg_crc.c src/datapagemap.c src/datapagemap.h src/logging.h \
EXTRA_CLEAN = src/pg_crc.c src/datapagemap.c src/datapagemap.h \
src/receivelog.c src/receivelog.h src/streamutil.c src/streamutil.h \
src/xlogreader.c
INCLUDES = src/datapagemap.h src/logging.h src/streamutil.h src/receivelog.h
INCLUDES = src/datapagemap.h src/streamutil.h src/receivelog.h
ifdef USE_PGXS
PG_CONFIG = pg_config
@ -39,12 +39,18 @@ else
srchome=$(top_srcdir)
endif
ifneq (12,$(MAJORVERSION))
EXTRA_CLEAN += src/logging.h
INCLUDES += src/logging.h
endif
ifeq (,$(filter 9.5 9.6,$(MAJORVERSION)))
OBJS += src/walmethods.o
EXTRA_CLEAN += src/walmethods.c src/walmethods.h
INCLUDES += src/walmethods.h
endif
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -Isrc -I$(top_srcdir)/$(subdir)/src
override CPPFLAGS := -DFRONTEND $(CPPFLAGS) $(PG_CPPFLAGS)
PG_LIBS_INTERNAL = $(libpq_pgport) ${PTHREAD_CFLAGS}
@ -70,10 +76,7 @@ src/streamutil.h: $(top_srcdir)/src/bin/pg_basebackup/streamutil.h
src/xlogreader.c: $(top_srcdir)/src/backend/access/transam/xlogreader.c
rm -f $@ && $(LN_S) $(srchome)/src/backend/access/transam/xlogreader.c $@
ifeq (12,$(MAJORVERSION))
src/logging.h: $(top_srcdir)/src/include/common/logging.h
rm -f $@ && $(LN_S) $(srchome)/src/include/common/logging.h $@
else
ifneq (12,$(MAJORVERSION))
src/logging.h: $(top_srcdir)/src/bin/pg_rewind/logging.h
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_rewind/logging.h $@
endif

View File

@ -17,6 +17,10 @@
#include "access/xlog_internal.h"
#include "utils/pg_crc.h"
#if PG_VERSION_NUM >= 120000
#include "common/logging.h"
#endif
#ifdef FRONTEND
#undef FRONTEND
#include <port/atomics.h>

View File

@ -88,6 +88,31 @@ init_logger(const char *root_path, LoggerConfig *config)
canonicalize_path(config->log_directory);
logger_config = *config;
#if PG_VERSION_NUM >= 120000
/* Setup logging for functions from other modules called by pg_probackup */
pg_logging_init(PROGRAM_NAME);
switch (logger_config.log_level_console)
{
case VERBOSE:
pg_logging_set_level(PG_LOG_DEBUG);
break;
case INFO:
case NOTICE:
case LOG:
pg_logging_set_level(PG_LOG_INFO);
break;
case WARNING:
pg_logging_set_level(PG_LOG_WARNING);
break;
case ERROR:
pg_logging_set_level(PG_LOG_ERROR);
break;
default:
break;
};
#endif
}
static void