mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
pgpro-2065. fix logging for checkdb command
This commit is contained in:
+8
-2
@@ -395,9 +395,15 @@ main(int argc, char *argv[])
|
||||
if (backup_path == NULL && backup_subcmd == CHECKDB_CMD)
|
||||
config_get_opt_env(instance_options);
|
||||
|
||||
if (backup_subcmd == CHECKDB_CMD
|
||||
&& (&instance_config.logger.log_level_file != LOG_OFF)
|
||||
&& (&instance_config.logger.log_directory == NULL))
|
||||
elog(ERROR, "Cannot save checkdb logs to a file. "
|
||||
"You must specify --log-directory option when running checkdb with "
|
||||
"--log-level-file option enabled.");
|
||||
|
||||
/* Initialize logger */
|
||||
if (backup_subcmd != CHECKDB_CMD)
|
||||
init_logger(backup_path, &instance_config.logger);
|
||||
init_logger(backup_path, &instance_config.logger);
|
||||
|
||||
/* command was initialized for a few commands */
|
||||
if (command)
|
||||
|
||||
+9
-5
@@ -71,12 +71,16 @@ static pthread_mutex_t log_file_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
void
|
||||
init_logger(const char *root_path, LoggerConfig *config)
|
||||
{
|
||||
/* Set log path */
|
||||
if (config->log_directory == NULL)
|
||||
/*
|
||||
* If logging to file is enabled and log_directory wasn't set
|
||||
* by user, init the path with default value: backup_directory/log/
|
||||
* */
|
||||
if (config->log_level_file != LOG_OFF
|
||||
&& config->log_directory == NULL)
|
||||
{
|
||||
config->log_directory = pgut_malloc(MAXPGPATH);
|
||||
join_path_components(config->log_directory,
|
||||
root_path, LOG_DIRECTORY_DEFAULT);
|
||||
config->log_directory = pgut_malloc(MAXPGPATH);
|
||||
join_path_components(config->log_directory,
|
||||
root_path, LOG_DIRECTORY_DEFAULT);
|
||||
}
|
||||
|
||||
logger_config = *config;
|
||||
|
||||
Reference in New Issue
Block a user