mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-09 14:45:47 +02:00
PGPRO-1700: Show default options in show-config
and clean up the code of the config options.
This commit is contained in:
parent
9a7daf009f
commit
e7d088c238
192
src/configure.c
192
src/configure.c
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "pg_probackup.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#include "pqexpbuffer.h"
|
||||
|
||||
@ -57,13 +58,17 @@ do_configure(bool show_only)
|
||||
config->master_db = master_db;
|
||||
if (master_user)
|
||||
config->master_user = master_user;
|
||||
if (replica_timeout != 300) /* 300 is default value */
|
||||
|
||||
if (replica_timeout)
|
||||
config->replica_timeout = replica_timeout;
|
||||
|
||||
if (log_level_console != LOG_NONE)
|
||||
config->log_level_console = LOG_LEVEL_CONSOLE;
|
||||
if (log_level_file != LOG_NONE)
|
||||
config->log_level_file = LOG_LEVEL_FILE;
|
||||
if (archive_timeout)
|
||||
config->archive_timeout = archive_timeout;
|
||||
|
||||
if (log_level_console)
|
||||
config->log_level_console = log_level_console;
|
||||
if (log_level_file)
|
||||
config->log_level_file = log_level_file;
|
||||
if (log_filename)
|
||||
config->log_filename = log_filename;
|
||||
if (error_log_filename)
|
||||
@ -80,9 +85,9 @@ do_configure(bool show_only)
|
||||
if (retention_window)
|
||||
config->retention_window = retention_window;
|
||||
|
||||
if (compress_alg != NOT_DEFINED_COMPRESS)
|
||||
if (compress_alg)
|
||||
config->compress_alg = compress_alg;
|
||||
if (compress_level != DEFAULT_COMPRESS_LEVEL)
|
||||
if (compress_level)
|
||||
config->compress_level = compress_level;
|
||||
|
||||
if (show_only)
|
||||
@ -107,21 +112,23 @@ pgBackupConfigInit(pgBackupConfig *config)
|
||||
config->master_port = NULL;
|
||||
config->master_db = NULL;
|
||||
config->master_user = NULL;
|
||||
config->replica_timeout = INT_MIN; /* INT_MIN means "undefined" */
|
||||
config->replica_timeout = REPLICA_TIMEOUT_DEFAULT;
|
||||
|
||||
config->log_level_console = INT_MIN; /* INT_MIN means "undefined" */
|
||||
config->log_level_file = INT_MIN; /* INT_MIN means "undefined" */
|
||||
config->log_filename = NULL;
|
||||
config->archive_timeout = ARCHIVE_TIMEOUT_DEFAULT;
|
||||
|
||||
config->log_level_console = LOG_LEVEL_CONSOLE_DEFAULT;
|
||||
config->log_level_file = LOG_LEVEL_FILE_DEFAULT;
|
||||
config->log_filename = LOG_FILENAME_DEFAULT;
|
||||
config->error_log_filename = NULL;
|
||||
config->log_directory = NULL;
|
||||
config->log_rotation_size = 0;
|
||||
config->log_rotation_age = 0;
|
||||
config->log_directory = LOG_DIRECTORY_DEFAULT;
|
||||
config->log_rotation_size = LOG_ROTATION_SIZE_DEFAULT;
|
||||
config->log_rotation_age = LOG_ROTATION_AGE_DEFAULT;
|
||||
|
||||
config->retention_redundancy = 0;
|
||||
config->retention_window = 0;
|
||||
config->retention_redundancy = RETENTION_REDUNDANCY_DEFAULT;
|
||||
config->retention_window = RETENTION_WINDOW_DEFAULT;
|
||||
|
||||
config->compress_alg = NOT_DEFINED_COMPRESS;
|
||||
config->compress_level = DEFAULT_COMPRESS_LEVEL;
|
||||
config->compress_alg = COMPRESS_ALG_DEFAULT;
|
||||
config->compress_level = COMPRESS_LEVEL_DEFAULT;
|
||||
}
|
||||
|
||||
void
|
||||
@ -154,55 +161,43 @@ writeBackupCatalogConfig(FILE *out, pgBackupConfig *config)
|
||||
if (config->master_user)
|
||||
fprintf(out, "master-user = %s\n", config->master_user);
|
||||
|
||||
if (config->replica_timeout != INT_MIN)
|
||||
{
|
||||
convert_from_base_unit_u(config->replica_timeout, OPTION_UNIT_S,
|
||||
&res, &unit);
|
||||
fprintf(out, "replica-timeout = " UINT64_FORMAT "%s\n", res, unit);
|
||||
}
|
||||
convert_from_base_unit_u(config->replica_timeout, OPTION_UNIT_S,
|
||||
&res, &unit);
|
||||
fprintf(out, "replica-timeout = " UINT64_FORMAT "%s\n", res, unit);
|
||||
|
||||
fprintf(out, "#Archive parameters:\n");
|
||||
convert_from_base_unit_u(config->archive_timeout, OPTION_UNIT_S,
|
||||
&res, &unit);
|
||||
fprintf(out, "archive-timeout = " UINT64_FORMAT "%s\n", res, unit);
|
||||
|
||||
fprintf(out, "#Logging parameters:\n");
|
||||
if (config->log_level_console != INT_MIN)
|
||||
fprintf(out, "log-level-console = %s\n", deparse_log_level(config->log_level_console));
|
||||
if (config->log_level_file != INT_MIN)
|
||||
fprintf(out, "log-level-file = %s\n", deparse_log_level(config->log_level_file));
|
||||
if (config->log_filename)
|
||||
fprintf(out, "log-filename = %s\n", config->log_filename);
|
||||
fprintf(out, "log-level-console = %s\n", deparse_log_level(config->log_level_console));
|
||||
fprintf(out, "log-level-file = %s\n", deparse_log_level(config->log_level_file));
|
||||
fprintf(out, "log-filename = %s\n", config->log_filename);
|
||||
if (config->error_log_filename)
|
||||
fprintf(out, "error-log-filename = %s\n", config->error_log_filename);
|
||||
if (config->log_directory)
|
||||
fprintf(out, "log-directory = %s\n", config->log_directory);
|
||||
|
||||
/*
|
||||
* Convert values from base unit
|
||||
*/
|
||||
if (config->log_rotation_size)
|
||||
{
|
||||
convert_from_base_unit_u(config->log_rotation_size, OPTION_UNIT_KB,
|
||||
&res, &unit);
|
||||
fprintf(out, "log-rotation-size = " UINT64_FORMAT "%s\n", res, unit);
|
||||
}
|
||||
if (config->log_rotation_age)
|
||||
{
|
||||
convert_from_base_unit_u(config->log_rotation_age, OPTION_UNIT_S,
|
||||
&res, &unit);
|
||||
fprintf(out, "log-rotation-age = " UINT64_FORMAT "%s\n", res, unit);
|
||||
}
|
||||
if (strcmp(config->log_directory, LOG_DIRECTORY_DEFAULT) == 0)
|
||||
fprintf(out, "log-directory = %s/%s\n", backup_path, config->log_directory);
|
||||
else
|
||||
fprintf(out, "log-directory = %s\n", config->log_directory);
|
||||
/* Convert values from base unit */
|
||||
convert_from_base_unit_u(config->log_rotation_size, OPTION_UNIT_KB,
|
||||
&res, &unit);
|
||||
fprintf(out, "log-rotation-size = " UINT64_FORMAT "%s\n", res, (res)?unit:"KB");
|
||||
|
||||
convert_from_base_unit_u(config->log_rotation_age, OPTION_UNIT_S,
|
||||
&res, &unit);
|
||||
fprintf(out, "log-rotation-age = " UINT64_FORMAT "%s\n", res, (res)?unit:"min");
|
||||
|
||||
fprintf(out, "#Retention parameters:\n");
|
||||
if (config->retention_redundancy)
|
||||
fprintf(out, "retention-redundancy = %u\n", config->retention_redundancy);
|
||||
if (config->retention_window)
|
||||
fprintf(out, "retention-window = %u\n", config->retention_window);
|
||||
fprintf(out, "retention-redundancy = %u\n", config->retention_redundancy);
|
||||
fprintf(out, "retention-window = %u\n", config->retention_window);
|
||||
|
||||
fprintf(out, "#Compression parameters:\n");
|
||||
|
||||
fprintf(out, "compress-algorithm = %s\n", deparse_compress_alg(config->compress_alg));
|
||||
|
||||
if (compress_level != config->compress_level)
|
||||
fprintf(out, "compress-level = %d\n", compress_level);
|
||||
else
|
||||
fprintf(out, "compress-level = %d\n", config->compress_level);
|
||||
fprintf(out, "compress-level = %d\n", config->compress_level);
|
||||
}
|
||||
|
||||
void
|
||||
@ -258,6 +253,8 @@ readBackupCatalogConfigFile(void)
|
||||
{ 'u', 0, "replica-timeout", &(config->replica_timeout), SOURCE_CMDLINE, SOURCE_DEFAULT, OPTION_UNIT_S },
|
||||
/* other options */
|
||||
{ 'U', 0, "system-identifier", &(config->system_identifier), SOURCE_FILE_STRICT },
|
||||
/* archive options */
|
||||
{ 'u', 0, "archive-timeout", &(config->archive_timeout), SOURCE_CMDLINE, SOURCE_DEFAULT, OPTION_UNIT_S },
|
||||
{0}
|
||||
};
|
||||
|
||||
@ -342,6 +339,8 @@ static void
|
||||
show_configure_json(pgBackupConfig *config)
|
||||
{
|
||||
PQExpBuffer buf = &show_buf;
|
||||
uint64 res;
|
||||
const char *unit;
|
||||
|
||||
json_add(buf, JT_BEGIN_OBJECT, &json_level);
|
||||
|
||||
@ -373,53 +372,60 @@ show_configure_json(pgBackupConfig *config)
|
||||
json_add_value(buf, "master-user", config->master_user, json_level,
|
||||
true);
|
||||
|
||||
if (config->replica_timeout != INT_MIN)
|
||||
{
|
||||
json_add_key(buf, "replica-timeout", json_level, true);
|
||||
appendPQExpBuffer(buf, "%d", config->replica_timeout);
|
||||
}
|
||||
json_add_key(buf, "replica-timeout", json_level, true);
|
||||
convert_from_base_unit_u(config->replica_timeout, OPTION_UNIT_S,
|
||||
&res, &unit);
|
||||
appendPQExpBuffer(buf, UINT64_FORMAT "%s", res, unit);
|
||||
|
||||
/* Archive parameters */
|
||||
json_add_key(buf, "archive-timeout", json_level, true);
|
||||
convert_from_base_unit_u(config->archive_timeout, OPTION_UNIT_S,
|
||||
&res, &unit);
|
||||
appendPQExpBuffer(buf, UINT64_FORMAT "%s", res, unit);
|
||||
|
||||
/* Logging parameters */
|
||||
if (config->log_level_console != INT_MIN)
|
||||
json_add_value(buf, "log-level-console",
|
||||
deparse_log_level(config->log_level_console), json_level,
|
||||
true);
|
||||
if (config->log_level_file != INT_MIN)
|
||||
json_add_value(buf, "log-level-file",
|
||||
deparse_log_level(config->log_level_file), json_level,
|
||||
true);
|
||||
if (config->log_filename)
|
||||
json_add_value(buf, "log-filename", config->log_filename, json_level,
|
||||
true);
|
||||
json_add_value(buf, "log-level-console",
|
||||
deparse_log_level(config->log_level_console), json_level,
|
||||
true);
|
||||
json_add_value(buf, "log-level-file",
|
||||
deparse_log_level(config->log_level_file), json_level,
|
||||
true);
|
||||
json_add_value(buf, "log-filename", config->log_filename, json_level,
|
||||
true);
|
||||
if (config->error_log_filename)
|
||||
json_add_value(buf, "error-log-filename", config->error_log_filename,
|
||||
json_level, true);
|
||||
if (config->log_directory)
|
||||
json_add_value(buf, "log-directory", config->log_directory, json_level,
|
||||
true);
|
||||
|
||||
if (config->log_rotation_size)
|
||||
if (strcmp(config->log_directory, LOG_DIRECTORY_DEFAULT) == 0)
|
||||
{
|
||||
json_add_key(buf, "log-rotation-size", json_level, true);
|
||||
appendPQExpBuffer(buf, "%d", config->log_rotation_size);
|
||||
}
|
||||
if (config->log_rotation_age)
|
||||
{
|
||||
json_add_key(buf, "log-rotation-age", json_level, true);
|
||||
appendPQExpBuffer(buf, "%d", config->log_rotation_age);
|
||||
char log_directory_fullpath[MAXPGPATH];
|
||||
|
||||
sprintf(log_directory_fullpath, "%s/%s",
|
||||
backup_path, config->log_directory);
|
||||
|
||||
json_add_value(buf, "log-directory", log_directory_fullpath,
|
||||
json_level, true);
|
||||
}
|
||||
else
|
||||
json_add_value(buf, "log-directory", config->log_directory,
|
||||
json_level, true);
|
||||
|
||||
json_add_key(buf, "log-rotation-size", json_level, true);
|
||||
convert_from_base_unit_u(config->log_rotation_size, OPTION_UNIT_KB,
|
||||
&res, &unit);
|
||||
appendPQExpBuffer(buf, UINT64_FORMAT "%s", res, (res)?unit:"KB");
|
||||
|
||||
json_add_key(buf, "log-rotation-age", json_level, true);
|
||||
convert_from_base_unit_u(config->log_rotation_age, OPTION_UNIT_S,
|
||||
&res, &unit);
|
||||
appendPQExpBuffer(buf, UINT64_FORMAT "%s", res, (res)?unit:"min");
|
||||
|
||||
/* Retention parameters */
|
||||
if (config->retention_redundancy)
|
||||
{
|
||||
json_add_key(buf, "retention-redundancy", json_level, true);
|
||||
appendPQExpBuffer(buf, "%u", config->retention_redundancy);
|
||||
}
|
||||
if (config->retention_window)
|
||||
{
|
||||
json_add_key(buf, "retention-window", json_level, true);
|
||||
appendPQExpBuffer(buf, "%u", config->retention_window);
|
||||
}
|
||||
json_add_key(buf, "retention-redundancy", json_level, true);
|
||||
appendPQExpBuffer(buf, "%u", config->retention_redundancy);
|
||||
|
||||
json_add_key(buf, "retention-window", json_level, true);
|
||||
appendPQExpBuffer(buf, "%u", config->retention_window);
|
||||
|
||||
/* Compression parameters */
|
||||
json_add_value(buf, "compress-algorithm",
|
||||
|
14
src/delete.c
14
src/delete.c
@ -141,7 +141,8 @@ do_retention_purge(void)
|
||||
if (retention_window > 0)
|
||||
elog(LOG, "WINDOW=%u", retention_window);
|
||||
|
||||
if (retention_redundancy == 0 && retention_window == 0)
|
||||
if (retention_redundancy == 0
|
||||
&& retention_window == 0)
|
||||
{
|
||||
elog(WARNING, "Retention policy is not set");
|
||||
if (!delete_wal)
|
||||
@ -161,7 +162,8 @@ do_retention_purge(void)
|
||||
}
|
||||
|
||||
/* Find target backups to be deleted */
|
||||
if (delete_expired && (retention_redundancy > 0 || retention_window > 0))
|
||||
if (delete_expired &&
|
||||
(retention_redundancy > 0 || retention_window > 0))
|
||||
{
|
||||
backup_num = 0;
|
||||
for (i = 0; i < parray_num(backup_list); i++)
|
||||
@ -173,13 +175,13 @@ do_retention_purge(void)
|
||||
if (backup->status != BACKUP_STATUS_OK)
|
||||
continue;
|
||||
/*
|
||||
* When a validate full backup was found, we can delete the
|
||||
* When a valid full backup was found, we can delete the
|
||||
* backup that is older than it using the number of generations.
|
||||
*/
|
||||
if (backup->backup_mode == BACKUP_MODE_FULL)
|
||||
backup_num++;
|
||||
|
||||
/* Evaluateretention_redundancy if this backup is eligible for removal */
|
||||
/* Evaluate retention_redundancy if this backup is eligible for removal */
|
||||
if (keep_next_backup ||
|
||||
retention_redundancy >= backup_num_evaluate + 1 ||
|
||||
(retention_window > 0 && backup->recovery_time >= days_threshold))
|
||||
@ -200,6 +202,7 @@ do_retention_purge(void)
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Delete backup and update status to DELETED */
|
||||
pgBackupDeleteFiles(backup);
|
||||
backup_deleted = true;
|
||||
@ -259,7 +262,8 @@ pgBackupDeleteFiles(pgBackup *backup)
|
||||
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time);
|
||||
|
||||
elog(INFO, "delete: %s %s", base36enc(backup->start_time), timestamp);
|
||||
elog(INFO, "delete: %s %s",
|
||||
base36enc(backup->start_time), timestamp);
|
||||
|
||||
/*
|
||||
* Update STATUS to BACKUP_STATUS_DELETING in preparation for the case which
|
||||
|
@ -87,6 +87,7 @@ help_pg_probackup(void)
|
||||
printf(_(" [--master-db=db_name] [--master-host=host_name]\n"));
|
||||
printf(_(" [--master-port=port] [--master-user=user_name]\n"));
|
||||
printf(_(" [--replica-timeout=timeout]\n"));
|
||||
printf(_(" [--archive-timeout=timeout]\n"));
|
||||
|
||||
printf(_("\n %s show-config -B backup-dir --instance=instance_name\n"), PROGRAM_NAME);
|
||||
printf(_(" [--format=format]\n"));
|
||||
@ -257,7 +258,7 @@ help_backup(void)
|
||||
printf(_(" --master-db=db_name database to connect to master\n"));
|
||||
printf(_(" --master-host=host_name database server host of master\n"));
|
||||
printf(_(" --master-port=port database server port of master\n"));
|
||||
printf(_(" --replica-timeout=timeout wait timeout for WAL segment streaming through replication in seconds\n"));
|
||||
printf(_(" --replica-timeout=timeout wait timeout for WAL segment streaming through replication (default: 5min)\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -429,6 +430,7 @@ help_set_config(void)
|
||||
printf(_(" [--master-db=db_name] [--master-host=host_name]\n"));
|
||||
printf(_(" [--master-port=port] [--master-user=user_name]\n"));
|
||||
printf(_(" [--replica-timeout=timeout]\n\n"));
|
||||
printf(_(" [--archive-timeout=timeout]\n\n"));
|
||||
|
||||
printf(_(" -B, --backup-path=backup-path location of the backup storage area\n"));
|
||||
printf(_(" --instance=instance_name name of the instance\n"));
|
||||
@ -477,7 +479,9 @@ help_set_config(void)
|
||||
printf(_(" --master-db=db_name database to connect to master\n"));
|
||||
printf(_(" --master-host=host_name database server host of master\n"));
|
||||
printf(_(" --master-port=port database server port of master\n"));
|
||||
printf(_(" --replica-timeout=timeout wait timeout for WAL segment streaming through replication\n"));
|
||||
printf(_(" --replica-timeout=timeout wait timeout for WAL segment streaming through replication (default: 5min)\n"));
|
||||
printf(_("\n Archive options:\n"));
|
||||
printf(_(" --archive-timeout=timeout wait timeout for WAL segment archiving (default: 5min)\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -51,12 +51,12 @@ bool backup_logs = false;
|
||||
bool smooth_checkpoint;
|
||||
bool is_remote_backup = false;
|
||||
/* Wait timeout for WAL segment archiving */
|
||||
uint32 archive_timeout = 300; /* default is 300 seconds */
|
||||
uint32 archive_timeout = ARCHIVE_TIMEOUT_DEFAULT;
|
||||
const char *master_db = NULL;
|
||||
const char *master_host = NULL;
|
||||
const char *master_port= NULL;
|
||||
const char *master_user = NULL;
|
||||
uint32 replica_timeout = 300; /* default is 300 seconds */
|
||||
uint32 replica_timeout = REPLICA_TIMEOUT_DEFAULT;
|
||||
|
||||
/* restore options */
|
||||
static char *target_time;
|
||||
@ -84,9 +84,10 @@ uint32 retention_redundancy = 0;
|
||||
uint32 retention_window = 0;
|
||||
|
||||
/* compression options */
|
||||
CompressAlg compress_alg = NOT_DEFINED_COMPRESS;
|
||||
int compress_level = DEFAULT_COMPRESS_LEVEL;
|
||||
bool compress_shortcut = false;
|
||||
CompressAlg compress_alg = COMPRESS_ALG_DEFAULT;
|
||||
int compress_level = COMPRESS_LEVEL_DEFAULT;
|
||||
bool compress_shortcut = false;
|
||||
|
||||
|
||||
/* other options */
|
||||
char *instance_name;
|
||||
@ -571,7 +572,7 @@ compress_init(void)
|
||||
|
||||
if (backup_subcmd != SET_CONFIG_CMD)
|
||||
{
|
||||
if (compress_level != DEFAULT_COMPRESS_LEVEL
|
||||
if (compress_level != COMPRESS_LEVEL_DEFAULT
|
||||
&& compress_alg == NOT_DEFINED_COMPRESS)
|
||||
elog(ERROR, "Cannot specify compress-level option without compress-alg option");
|
||||
}
|
||||
|
@ -63,6 +63,8 @@
|
||||
#define PG_BLACK_LIST "black_list"
|
||||
#define PG_TABLESPACE_MAP_FILE "tablespace_map"
|
||||
|
||||
#define LOG_FILENAME_DEFAULT "pg_probackup.log"
|
||||
#define LOG_DIRECTORY_DEFAULT "log"
|
||||
/* Direcotry/File permission */
|
||||
#define DIR_PERMISSION (0700)
|
||||
#define FILE_PERMISSION (0600)
|
||||
@ -182,6 +184,8 @@ typedef struct pgBackupConfig
|
||||
const char *master_user;
|
||||
int replica_timeout;
|
||||
|
||||
int archive_timeout;
|
||||
|
||||
int log_level_console;
|
||||
int log_level_file;
|
||||
char *log_filename;
|
||||
@ -334,12 +338,14 @@ extern char *replication_slot;
|
||||
|
||||
/* backup options */
|
||||
extern bool smooth_checkpoint;
|
||||
#define ARCHIVE_TIMEOUT_DEFAULT 300
|
||||
extern uint32 archive_timeout;
|
||||
extern bool is_remote_backup;
|
||||
extern const char *master_db;
|
||||
extern const char *master_host;
|
||||
extern const char *master_port;
|
||||
extern const char *master_user;
|
||||
#define REPLICA_TIMEOUT_DEFAULT 300
|
||||
extern uint32 replica_timeout;
|
||||
|
||||
extern bool is_ptrack_support;
|
||||
@ -355,7 +361,10 @@ extern bool delete_expired;
|
||||
extern bool apply_to_all;
|
||||
extern bool force_delete;
|
||||
|
||||
/* retention options */
|
||||
/* retention options. 0 disables the option */
|
||||
#define RETENTION_REDUNDANCY_DEFAULT 0
|
||||
#define RETENTION_WINDOW_DEFAULT 0
|
||||
|
||||
extern uint32 retention_redundancy;
|
||||
extern uint32 retention_window;
|
||||
|
||||
@ -364,7 +373,8 @@ extern CompressAlg compress_alg;
|
||||
extern int compress_level;
|
||||
extern bool compress_shortcut;
|
||||
|
||||
#define DEFAULT_COMPRESS_LEVEL 1
|
||||
#define COMPRESS_ALG_DEFAULT NOT_DEFINED_COMPRESS
|
||||
#define COMPRESS_LEVEL_DEFAULT 1
|
||||
|
||||
extern CompressAlg parse_compress_alg(const char *arg);
|
||||
extern const char* deparse_compress_alg(int alg);
|
||||
|
@ -14,8 +14,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "catalog/pg_control.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/thread.h"
|
||||
|
||||
typedef struct
|
||||
@ -455,7 +457,7 @@ restore_backup(pgBackup *backup)
|
||||
parray_walk(files, pgFileFree);
|
||||
parray_free(files);
|
||||
|
||||
if (LOG_LEVEL_CONSOLE <= LOG || LOG_LEVEL_FILE <= LOG)
|
||||
if (log_level_console <= LOG || log_level_file <= LOG)
|
||||
elog(LOG, "restore %s backup completed", base36enc(backup->start_time));
|
||||
}
|
||||
|
||||
@ -492,7 +494,7 @@ remove_deleted_files(pgBackup *backup)
|
||||
if (parray_bsearch(files, file, pgFileComparePathDesc) == NULL)
|
||||
{
|
||||
pgFileDelete(file);
|
||||
if (LOG_LEVEL_CONSOLE <= LOG || LOG_LEVEL_FILE <= LOG)
|
||||
if (log_level_console <= LOG || log_level_file <= LOG)
|
||||
elog(LOG, "deleted %s", GetRelativePath(file->path, pgdata));
|
||||
}
|
||||
}
|
||||
@ -667,7 +669,7 @@ check_tablespace_mapping(pgBackup *backup)
|
||||
pgBackupGetPath(backup, this_backup_path, lengthof(this_backup_path), NULL);
|
||||
read_tablespace_map(links, this_backup_path);
|
||||
|
||||
if (LOG_LEVEL_CONSOLE <= LOG || LOG_LEVEL_FILE <= LOG)
|
||||
if (log_level_console <= LOG || log_level_file <= LOG)
|
||||
elog(LOG, "check tablespace directories of backup %s",
|
||||
base36enc(backup->start_time));
|
||||
|
||||
|
@ -341,8 +341,8 @@ pgBackup_init(pgBackup *backup)
|
||||
backup->data_bytes = BYTES_INVALID;
|
||||
backup->wal_bytes = BYTES_INVALID;
|
||||
|
||||
backup->compress_alg = NOT_DEFINED_COMPRESS;
|
||||
backup->compress_level = 0;
|
||||
backup->compress_alg = COMPRESS_ALG_DEFAULT;
|
||||
backup->compress_level = COMPRESS_LEVEL_DEFAULT;
|
||||
|
||||
backup->block_size = BLCKSZ;
|
||||
backup->wal_block_size = XLOG_BLCKSZ;
|
||||
|
@ -15,12 +15,13 @@
|
||||
|
||||
#include "logger.h"
|
||||
#include "pgut.h"
|
||||
#include "pg_probackup.h"
|
||||
#include "thread.h"
|
||||
|
||||
/* Logger parameters */
|
||||
|
||||
int log_level_console = LOG_NONE;
|
||||
int log_level_file = LOG_NONE;
|
||||
int log_level_console = LOG_LEVEL_CONSOLE_DEFAULT;
|
||||
int log_level_file = LOG_LEVEL_FILE_DEFAULT;
|
||||
|
||||
char *log_filename = NULL;
|
||||
char *error_log_filename = NULL;
|
||||
@ -74,12 +75,12 @@ void
|
||||
init_logger(const char *root_path)
|
||||
{
|
||||
/* Set log path */
|
||||
if (LOG_LEVEL_FILE != LOG_OFF || error_log_filename)
|
||||
if (log_level_file != LOG_OFF || error_log_filename)
|
||||
{
|
||||
if (log_directory)
|
||||
strcpy(log_path, log_directory);
|
||||
else
|
||||
join_path_components(log_path, root_path, "log");
|
||||
join_path_components(log_path, root_path, LOG_DIRECTORY_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,10 +166,10 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
|
||||
time_t log_time = (time_t) time(NULL);
|
||||
char strfbuf[128];
|
||||
|
||||
write_to_file = elevel >= LOG_LEVEL_FILE && log_path[0] != '\0';
|
||||
write_to_file = elevel >= log_level_file && log_path[0] != '\0';
|
||||
write_to_error_log = elevel >= ERROR && error_log_filename &&
|
||||
log_path[0] != '\0';
|
||||
write_to_stderr = elevel >= LOG_LEVEL_CONSOLE && !file_only;
|
||||
write_to_stderr = elevel >= log_level_console && !file_only;
|
||||
|
||||
pthread_lock(&log_file_mutex);
|
||||
#ifdef WIN32
|
||||
@ -201,7 +202,7 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
|
||||
if (log_file == NULL)
|
||||
{
|
||||
if (log_filename == NULL)
|
||||
open_logfile(&log_file, "pg_probackup.log");
|
||||
open_logfile(&log_file, LOG_FILENAME_DEFAULT);
|
||||
else
|
||||
open_logfile(&log_file, log_filename);
|
||||
}
|
||||
@ -271,7 +272,7 @@ elog_stderr(int elevel, const char *fmt, ...)
|
||||
* Do not log message if severity level is less than log_level.
|
||||
* It is the little optimisation to put it here not in elog_internal().
|
||||
*/
|
||||
if (elevel < LOG_LEVEL_CONSOLE && elevel < ERROR)
|
||||
if (elevel < log_level_console && elevel < ERROR)
|
||||
return;
|
||||
|
||||
va_start(args, fmt);
|
||||
@ -298,7 +299,7 @@ elog(int elevel, const char *fmt, ...)
|
||||
* Do not log message if severity level is less than log_level.
|
||||
* It is the little optimisation to put it here not in elog_internal().
|
||||
*/
|
||||
if (elevel < LOG_LEVEL_CONSOLE && elevel < LOG_LEVEL_FILE && elevel < ERROR)
|
||||
if (elevel < log_level_console && elevel < log_level_file && elevel < ERROR)
|
||||
return;
|
||||
|
||||
va_start(args, fmt);
|
||||
@ -318,7 +319,7 @@ elog_file(int elevel, const char *fmt, ...)
|
||||
* Do not log message if severity level is less than log_level.
|
||||
* It is the little optimisation to put it here not in elog_internal().
|
||||
*/
|
||||
if (elevel < LOG_LEVEL_FILE && elevel < ERROR)
|
||||
if (elevel < log_level_file && elevel < ERROR)
|
||||
return;
|
||||
|
||||
va_start(args, fmt);
|
||||
@ -359,7 +360,7 @@ pg_log(eLogType type, const char *fmt, ...)
|
||||
* Do not log message if severity level is less than log_level.
|
||||
* It is the little optimisation to put it here not in elog_internal().
|
||||
*/
|
||||
if (elevel < LOG_LEVEL_CONSOLE && elevel < LOG_LEVEL_FILE && elevel < ERROR)
|
||||
if (elevel < log_level_console && elevel < log_level_file && elevel < ERROR)
|
||||
return;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
@ -36,11 +36,13 @@ extern char *error_log_filename;
|
||||
extern char *log_directory;
|
||||
extern char log_path[MAXPGPATH];
|
||||
|
||||
#define LOG_ROTATION_SIZE_DEFAULT 0
|
||||
#define LOG_ROTATION_AGE_DEFAULT 0
|
||||
extern int log_rotation_size;
|
||||
extern int log_rotation_age;
|
||||
|
||||
#define LOG_LEVEL_CONSOLE ((log_level_console == LOG_NONE) ? INFO : log_level_console)
|
||||
#define LOG_LEVEL_FILE ((log_level_file == LOG_NONE) ? LOG_OFF : log_level_file)
|
||||
#define LOG_LEVEL_CONSOLE_DEFAULT INFO
|
||||
#define LOG_LEVEL_FILE_DEFAULT LOG_OFF
|
||||
|
||||
#undef elog
|
||||
extern void elog(int elevel, const char *fmt, ...) pg_attribute_printf(2, 3);
|
||||
|
@ -1680,7 +1680,7 @@ pgut_execute_parallel(PGconn* conn,
|
||||
elog(ERROR, "interrupted");
|
||||
|
||||
/* write query to elog if verbose */
|
||||
if (LOG_LEVEL_CONSOLE <= VERBOSE || LOG_LEVEL_FILE <= VERBOSE)
|
||||
if (log_level_console <= VERBOSE || log_level_file <= VERBOSE)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -1742,7 +1742,7 @@ pgut_execute_extended(PGconn* conn, const char *query, int nParams,
|
||||
elog(ERROR, "interrupted");
|
||||
|
||||
/* write query to elog if verbose */
|
||||
if (LOG_LEVEL_CONSOLE <= VERBOSE || LOG_LEVEL_FILE <= VERBOSE)
|
||||
if (log_level_console <= VERBOSE || log_level_file <= VERBOSE)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -1800,7 +1800,7 @@ pgut_send(PGconn* conn, const char *query, int nParams, const char **params, int
|
||||
elog(ERROR, "interrupted");
|
||||
|
||||
/* write query to elog if verbose */
|
||||
if (LOG_LEVEL_CONSOLE <= VERBOSE || LOG_LEVEL_FILE <= VERBOSE)
|
||||
if (log_level_console <= VERBOSE || log_level_file <= VERBOSE)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user