From c094151b911455ca6b7b11204b47e15d8c2541a9 Mon Sep 17 00:00:00 2001 From: Arthur Zakirov Date: Tue, 7 Aug 2018 13:28:02 +0300 Subject: [PATCH 1/2] Remove FATAL, PANIC log levels --- src/backup.c | 2 +- src/utils/logger.c | 22 ++++------------------ src/utils/logger.h | 2 -- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/backup.c b/src/backup.c index 9a4c7005..20163b5d 100644 --- a/src/backup.c +++ b/src/backup.c @@ -1663,7 +1663,7 @@ pg_stop_backup(pgBackup *backup) TransactionId recovery_xid; if (!backup_in_progress) - elog(FATAL, "backup is not in progress"); + elog(ERROR, "backup is not in progress"); /* For replica we call pg_stop_backup() on master */ conn = (current.from_replica) ? master_conn : backup_conn; diff --git a/src/utils/logger.c b/src/utils/logger.c index 88ee9b6b..31669ed0 100644 --- a/src/utils/logger.c +++ b/src/utils/logger.c @@ -107,12 +107,6 @@ write_elevel(FILE *stream, int elevel) case ERROR: fputs("ERROR: ", stream); break; - case FATAL: - fputs("FATAL: ", stream); - break; - case PANIC: - fputs("PANIC: ", stream); - break; default: elog_stderr(ERROR, "invalid logging level: %d", elevel); break; @@ -151,7 +145,7 @@ exit_if_necessary(int elevel) } /* - * Logs to stderr or to log file and exit if ERROR or FATAL. + * Logs to stderr or to log file and exit if ERROR. * * Actual implementation for elog() and pg_log(). */ @@ -288,7 +282,7 @@ elog_stderr(int elevel, const char *fmt, ...) } /* - * Logs to stderr or to log file and exit if ERROR or FATAL. + * Logs to stderr or to log file and exit if ERROR. */ void elog(int elevel, const char *fmt, ...) @@ -308,7 +302,7 @@ elog(int elevel, const char *fmt, ...) } /* - * Logs only to log file and exit if ERROR or FATAL. + * Logs only to log file and exit if ERROR. */ void elog_file(int elevel, const char *fmt, ...) @@ -399,10 +393,6 @@ parse_log_level(const char *level) return WARNING; else if (pg_strncasecmp("error", v, len) == 0) return ERROR; - else if (pg_strncasecmp("fatal", v, len) == 0) - return FATAL; - else if (pg_strncasecmp("panic", v, len) == 0) - return PANIC; /* Log level is invalid */ elog(ERROR, "invalid log-level \"%s\"", level); @@ -431,10 +421,6 @@ deparse_log_level(int level) return "WARNING"; case ERROR: return "ERROR"; - case FATAL: - return "FATAL"; - case PANIC: - return "PANIC"; default: elog(ERROR, "invalid log-level %d", level); } @@ -491,7 +477,7 @@ logfile_open(const char *filename, const char *mode) { int save_errno = errno; - elog_stderr(FATAL, "could not open log file \"%s\": %s", + elog_stderr(ERROR, "could not open log file \"%s\": %s", filename, strerror(errno)); errno = save_errno; } diff --git a/src/utils/logger.h b/src/utils/logger.h index 0177c551..8643ad18 100644 --- a/src/utils/logger.h +++ b/src/utils/logger.h @@ -21,8 +21,6 @@ #define NOTICE (-2) #define WARNING (-1) #define ERROR 1 -#define FATAL 2 -#define PANIC 3 #define LOG_OFF 10 /* Logger parameters */ From ee7812c72fdad9b2f04ca5cdaf3ef43fbeaf915d Mon Sep 17 00:00:00 2001 From: Arthur Zakirov Date: Tue, 7 Aug 2018 13:40:14 +0300 Subject: [PATCH 2/2] Fix help typos --- src/help.c | 98 +++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 46 deletions(-) diff --git a/src/help.c b/src/help.c index 9ad6cc2e..7fa9c9ed 100644 --- a/src/help.c +++ b/src/help.c @@ -74,7 +74,7 @@ help_pg_probackup(void) printf(_("\n %s init -B backup-path\n"), PROGRAM_NAME); - printf(_("\n %s set-config -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("\n %s set-config -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" [--log-level-console=log-level-console]\n")); printf(_(" [--log-level-file=log-level-file]\n")); printf(_(" [--log-filename=log-filename]\n")); @@ -92,7 +92,7 @@ help_pg_probackup(void) 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(_("\n %s show-config -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" [--format=format]\n")); printf(_("\n %s backup -B backup-path -b backup-mode --instance=instance_name\n"), PROGRAM_NAME); @@ -118,8 +118,8 @@ help_pg_probackup(void) printf(_(" [--master-port=port] [--master-user=user_name]\n")); printf(_(" [--replica-timeout=timeout]\n")); - printf(_("\n %s restore -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); - printf(_(" [-D pgdata-dir] [-i backup-id] [--progress]\n")); + printf(_("\n %s restore -B backup-path --instance=instance_name\n"), PROGRAM_NAME); + printf(_(" [-D pgdata-path] [-i backup-id] [--progress]\n")); printf(_(" [--time=time|--xid=xid|--lsn=lsn [--inclusive=boolean]]\n")); printf(_(" [--timeline=timeline] [-T OLDDIR=NEWDIR]\n")); printf(_(" [--immediate] [--recovery-target-name=target-name]\n")); @@ -127,34 +127,36 @@ help_pg_probackup(void) printf(_(" [--restore-as-replica]\n")); printf(_(" [--no-validate]\n")); - printf(_("\n %s validate -B backup-dir [--instance=instance_name]\n"), PROGRAM_NAME); + printf(_("\n %s validate -B backup-path [--instance=instance_name]\n"), PROGRAM_NAME); printf(_(" [-i backup-id] [--progress]\n")); printf(_(" [--time=time|--xid=xid|--lsn=lsn [--inclusive=boolean]]\n")); printf(_(" [--recovery-target-name=target-name]\n")); printf(_(" [--timeline=timeline]\n")); - printf(_("\n %s show -B backup-dir\n"), PROGRAM_NAME); + printf(_("\n %s show -B backup-path\n"), PROGRAM_NAME); printf(_(" [--instance=instance_name [-i backup-id]]\n")); printf(_(" [--format=format]\n")); - printf(_("\n %s delete -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("\n %s delete -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" [--wal] [-i backup-id | --expired]\n")); - printf(_("\n %s merge -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("\n %s merge -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" -i backup-id\n")); - printf(_("\n %s add-instance -B backup-dir -D pgdata-dir\n"), PROGRAM_NAME); + printf(_("\n %s add-instance -B backup-path -D pgdata-path\n"), PROGRAM_NAME); printf(_(" --instance=instance_name\n")); - printf(_("\n %s del-instance -B backup-dir\n"), PROGRAM_NAME); + printf(_("\n %s del-instance -B backup-path\n"), PROGRAM_NAME); printf(_(" --instance=instance_name\n")); - printf(_("\n %s archive-push -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("\n %s archive-push -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" --wal-file-path=wal-file-path\n")); printf(_(" --wal-file-name=wal-file-name\n")); - printf(_(" [--compress [--compress-level=compress-level]]\n")); + printf(_(" [--compress]\n")); + printf(_(" [--compress-algorithm=compress-algorithm]\n")); + printf(_(" [--compress-level=compress-level]\n")); printf(_(" [--overwrite]\n")); - printf(_("\n %s archive-get -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("\n %s archive-get -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" --wal-file-path=wal-file-path\n")); printf(_(" --wal-file-name=wal-file-name\n")); @@ -228,10 +230,10 @@ help_backup(void) printf(_(" --log-directory=log-directory\n")); printf(_(" directory for file logging (default: BACKUP_PATH/log)\n")); printf(_(" --log-rotation-size=log-rotation-size\n")); - printf(_(" rotate logfile if its size exceed this value; 0 disables; (default: 0)\n")); - printf(_(" available units: 'KB', 'MB', 'GB', 'TB' (default: KB)\n")); + printf(_(" rotate logfile if its size exceeds this value; 0 disables; (default: 0)\n")); + printf(_(" available units: 'kB', 'MB', 'GB', 'TB' (default: kB)\n")); printf(_(" --log-rotation-age=log-rotation-age\n")); - printf(_(" rotate logfile if its age exceed this value; 0 disables; (default: 0)\n")); + printf(_(" rotate logfile if its age exceeds this value; 0 disables; (default: 0)\n")); printf(_(" available units: 'ms', 's', 'min', 'h', 'd' (default: min)\n")); printf(_("\n Retention options:\n")); @@ -269,8 +271,8 @@ help_backup(void) static void help_restore(void) { - printf(_("%s restore -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); - printf(_(" [-D pgdata-dir] [-i backup-id] [--progress]\n")); + printf(_("%s restore -B backup-path --instance=instance_name\n"), PROGRAM_NAME); + printf(_(" [-D pgdata-path] [-i backup-id] [--progress]\n")); printf(_(" [--time=time|--xid=xid|--lsn=lsn [--inclusive=boolean]]\n")); printf(_(" [--timeline=timeline] [-T OLDDIR=NEWDIR]\n")); printf(_(" [--immediate] [--recovery-target-name=target-name]\n")); @@ -280,7 +282,7 @@ help_restore(void) printf(_(" -B, --backup-path=backup-path location of the backup storage area\n")); printf(_(" --instance=instance_name name of the instance\n")); - printf(_(" -D, --pgdata=pgdata-dir location of the database storage area\n")); + printf(_(" -D, --pgdata=pgdata-path location of the database storage area\n")); printf(_(" -i, --backup-id=backup-id backup to restore\n")); printf(_(" --progress show progress\n")); @@ -318,17 +320,17 @@ help_restore(void) printf(_(" --log-directory=log-directory\n")); printf(_(" directory for file logging (default: BACKUP_PATH/log)\n")); printf(_(" --log-rotation-size=log-rotation-size\n")); - printf(_(" rotate logfile if its size exceed this value; 0 disables; (default: 0)\n")); - printf(_(" available units: 'KB', 'MB', 'GB', 'TB' (default: KB)\n")); + printf(_(" rotate logfile if its size exceeds this value; 0 disables; (default: 0)\n")); + printf(_(" available units: 'kB', 'MB', 'GB', 'TB' (default: kB)\n")); printf(_(" --log-rotation-age=log-rotation-age\n")); - printf(_(" rotate logfile if its age exceed this value; 0 disables; (default: 0)\n")); + printf(_(" rotate logfile if its age exceeds this value; 0 disables; (default: 0)\n")); printf(_(" available units: 'ms', 's', 'min', 'h', 'd' (default: min)\n")); } static void help_validate(void) { - printf(_("%s validate -B backup-dir [--instance=instance_name]\n"), PROGRAM_NAME); + printf(_("%s validate -B backup-path [--instance=instance_name]\n"), PROGRAM_NAME); printf(_(" [-i backup-id] [--progress]\n")); printf(_(" [--time=time|--xid=xid|--lsn=lsn [--inclusive=boolean]]\n")); printf(_(" [--timeline=timeline]\n\n")); @@ -361,17 +363,17 @@ help_validate(void) printf(_(" --log-directory=log-directory\n")); printf(_(" directory for file logging (default: BACKUP_PATH/log)\n")); printf(_(" --log-rotation-size=log-rotation-size\n")); - printf(_(" rotate logfile if its size exceed this value; 0 disables; (default: 0)\n")); - printf(_(" available units: 'KB', 'MB', 'GB', 'TB' (default: KB)\n")); + printf(_(" rotate logfile if its size exceeds this value; 0 disables; (default: 0)\n")); + printf(_(" available units: 'kB', 'MB', 'GB', 'TB' (default: kB)\n")); printf(_(" --log-rotation-age=log-rotation-age\n")); - printf(_(" rotate logfile if its age exceed this value; 0 disables; (default: 0)\n")); + printf(_(" rotate logfile if its age exceeds this value; 0 disables; (default: 0)\n")); printf(_(" available units: 'ms', 's', 'min', 'h', 'd' (default: min)\n")); } static void help_show(void) { - printf(_("%s show -B backup-dir\n"), PROGRAM_NAME); + printf(_("%s show -B backup-path\n"), PROGRAM_NAME); printf(_(" [--instance=instance_name [-i backup-id]]\n")); printf(_(" [--format=format]\n\n")); @@ -384,7 +386,7 @@ help_show(void) static void help_delete(void) { - printf(_("%s delete -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("%s delete -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" [-i backup-id | --expired] [--wal]\n\n")); printf(_(" -B, --backup-path=backup-path location of the backup storage area\n")); @@ -409,17 +411,17 @@ help_delete(void) printf(_(" --log-directory=log-directory\n")); printf(_(" directory for file logging (default: BACKUP_PATH/log)\n")); printf(_(" --log-rotation-size=log-rotation-size\n")); - printf(_(" rotate logfile if its size exceed this value; 0 disables; (default: 0)\n")); - printf(_(" available units: 'KB', 'MB', 'GB', 'TB' (default: KB)\n")); + printf(_(" rotate logfile if its size exceeds this value; 0 disables; (default: 0)\n")); + printf(_(" available units: 'kB', 'MB', 'GB', 'TB' (default: kB)\n")); printf(_(" --log-rotation-age=log-rotation-age\n")); - printf(_(" rotate logfile if its age exceed this value; 0 disables; (default: 0)\n")); + printf(_(" rotate logfile if its age exceeds this value; 0 disables; (default: 0)\n")); printf(_(" available units: 'ms', 's', 'min', 'h', 'd' (default: min)\n")); } static void help_merge(void) { - printf(_("%s merge -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("%s merge -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" -i backup-id [-j num-threads] [--progress]\n")); printf(_(" [--log-level-console=log-level-console]\n")); printf(_(" [--log-level-file=log-level-file]\n")); @@ -451,17 +453,17 @@ help_merge(void) printf(_(" --log-directory=log-directory\n")); printf(_(" directory for file logging (default: BACKUP_PATH/log)\n")); printf(_(" --log-rotation-size=log-rotation-size\n")); - printf(_(" rotate logfile if its size exceed this value; 0 disables; (default: 0)\n")); - printf(_(" available units: 'KB', 'MB', 'GB', 'TB' (default: KB)\n")); + printf(_(" rotate logfile if its size exceeds this value; 0 disables; (default: 0)\n")); + printf(_(" available units: 'kB', 'MB', 'GB', 'TB' (default: kB)\n")); printf(_(" --log-rotation-age=log-rotation-age\n")); - printf(_(" rotate logfile if its age exceed this value; 0 disables; (default: 0)\n")); + printf(_(" rotate logfile if its age exceeds this value; 0 disables; (default: 0)\n")); printf(_(" available units: 'ms', 's', 'min', 'h', 'd' (default: min)\n")); } static void help_set_config(void) { - printf(_("%s set-config -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("%s set-config -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" [--log-level-console=log-level-console]\n")); printf(_(" [--log-level-file=log-level-file]\n")); printf(_(" [--log-filename=log-filename]\n")); @@ -497,10 +499,10 @@ help_set_config(void) printf(_(" --log-directory=log-directory\n")); printf(_(" directory for file logging (default: BACKUP_PATH/log)\n")); printf(_(" --log-rotation-size=log-rotation-size\n")); - printf(_(" rotate logfile if its size exceed this value; 0 disables; (default: 0)\n")); - printf(_(" available units: 'KB', 'MB', 'GB', 'TB' (default: KB)\n")); + printf(_(" rotate logfile if its size exceeds this value; 0 disables; (default: 0)\n")); + printf(_(" available units: 'kB', 'MB', 'GB', 'TB' (default: kB)\n")); printf(_(" --log-rotation-age=log-rotation-age\n")); - printf(_(" rotate logfile if its age exceed this value; 0 disables; (default: 0)\n")); + printf(_(" rotate logfile if its age exceeds this value; 0 disables; (default: 0)\n")); printf(_(" available units: 'ms', 's', 'min', 'h', 'd' (default: min)\n")); printf(_("\n Retention options:\n")); @@ -534,7 +536,7 @@ help_set_config(void) static void help_show_config(void) { - printf(_("%s show-config -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("%s show-config -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" [--format=format]\n\n")); printf(_(" -B, --backup-path=backup-path location of the backup storage area\n")); @@ -545,18 +547,18 @@ help_show_config(void) static void help_add_instance(void) { - printf(_("%s add-instance -B backup-dir -D pgdata-dir\n"), PROGRAM_NAME); + printf(_("%s add-instance -B backup-path -D pgdata-path\n"), PROGRAM_NAME); printf(_(" --instance=instance_name\n\n")); printf(_(" -B, --backup-path=backup-path location of the backup storage area\n")); - printf(_(" -D, --pgdata=pgdata-dir location of the database storage area\n")); + printf(_(" -D, --pgdata=pgdata-path location of the database storage area\n")); printf(_(" --instance=instance_name name of the new instance\n")); } static void help_del_instance(void) { - printf(_("%s del-instance -B backup-dir --instance=instance_name\n\n"), PROGRAM_NAME); + printf(_("%s del-instance -B backup-path --instance=instance_name\n\n"), PROGRAM_NAME); printf(_(" -B, --backup-path=backup-path location of the backup storage area\n")); printf(_(" --instance=instance_name name of the instance to delete\n")); @@ -565,10 +567,12 @@ help_del_instance(void) static void help_archive_push(void) { - printf(_("\n %s archive-push -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("\n %s archive-push -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" --wal-file-path=wal-file-path\n")); printf(_(" --wal-file-name=wal-file-name\n")); - printf(_(" [--compress [--compress-level=compress-level]]\n")); + printf(_(" [--compress]\n")); + printf(_(" [--compress-algorithm=compress-algorithm]\n")); + printf(_(" [--compress-level=compress-level]\n")); printf(_(" [--overwrite]\n\n")); printf(_(" -B, --backup-path=backup-path location of the backup storage area\n")); @@ -578,6 +582,8 @@ help_archive_push(void) printf(_(" --wal-file-name=wal-file-name\n")); printf(_(" name of the WAL file to retrieve from the server\n")); printf(_(" --compress compress WAL file during archiving\n")); + printf(_(" --compress-algorithm=compress-algorithm\n")); + printf(_(" available options: 'zlib','none'\n")); printf(_(" --compress-level=compress-level\n")); printf(_(" level of compression [0-9]\n")); printf(_(" --overwrite overwrite archived WAL file\n")); @@ -586,7 +592,7 @@ help_archive_push(void) static void help_archive_get(void) { - printf(_("\n %s archive-get -B backup-dir --instance=instance_name\n"), PROGRAM_NAME); + printf(_("\n %s archive-get -B backup-path --instance=instance_name\n"), PROGRAM_NAME); printf(_(" --wal-file-path=wal-file-path\n")); printf(_(" --wal-file-name=wal-file-name\n\n"));