99
1010#include "pg_probackup.h"
1111
12- static void opt_log_level (pgut_option * opt , const char * arg );
12+ static void opt_log_level_console (pgut_option * opt , const char * arg );
13+ static void opt_log_level_file (pgut_option * opt , const char * arg );
1314static void opt_compress_alg (pgut_option * opt , const char * arg );
1415
1516static pgBackupConfig * cur_config = NULL ;
@@ -41,10 +42,10 @@ do_configure(bool show_only)
4142 if (replica_timeout != 300 ) /* 300 is default value */
4243 config -> replica_timeout = replica_timeout ;
4344
44- if (log_to_file != LOGGER_NONE )
45- config -> log_to_file = LOG_TO_FILE ;
46- if (log_level != LOGGER_NONE )
47- config -> log_level = LOG_LEVEL ;
45+ if (log_level_console != LOG_NONE )
46+ config -> log_level_console = LOG_LEVEL_CONSOLE ;
47+ if (log_level_file != LOG_NONE )
48+ config -> log_level_file = LOG_LEVEL_FILE ;
4849 if (log_filename )
4950 config -> log_filename = log_filename ;
5051 if (error_log_filename )
@@ -90,8 +91,8 @@ pgBackupConfigInit(pgBackupConfig *config)
9091 config -> master_user = NULL ;
9192 config -> replica_timeout = INT_MIN ; /* INT_MIN means "undefined" */
9293
93- config -> log_to_file = INT_MIN ; /* INT_MIN means "undefined" */
94- config -> log_level = INT_MIN ; /* INT_MIN means "undefined" */
94+ config -> log_level_console = INT_MIN ; /* INT_MIN means "undefined" */
95+ config -> log_level_file = INT_MIN ; /* INT_MIN means "undefined" */
9596 config -> log_filename = NULL ;
9697 config -> error_log_filename = NULL ;
9798 config -> log_directory = NULL ;
@@ -108,6 +109,9 @@ pgBackupConfigInit(pgBackupConfig *config)
108109void
109110writeBackupCatalogConfig (FILE * out , pgBackupConfig * config )
110111{
112+ uint64 res ;
113+ const char * unit ;
114+
111115 fprintf (out , "#Backup instance info\n" );
112116 fprintf (out , "PGDATA = %s\n" , config -> pgdata );
113117 fprintf (out , "system-identifier = %li\n" , config -> system_identifier );
@@ -131,24 +135,41 @@ writeBackupCatalogConfig(FILE *out, pgBackupConfig *config)
131135 fprintf (out , "master-db = %s\n" , config -> master_db );
132136 if (config -> master_user )
133137 fprintf (out , "master-user = %s\n" , config -> master_user );
138+
134139 if (config -> replica_timeout != INT_MIN )
135- fprintf (out , "replica_timeout = %d\n" , config -> replica_timeout );
140+ {
141+ convert_from_base_unit_u (config -> replica_timeout , OPTION_UNIT_S ,
142+ & res , & unit );
143+ fprintf (out , "replica-timeout = " UINT64_FORMAT "%s\n" , res , unit );
144+ }
136145
137146 fprintf (out , "#Logging parameters:\n" );
138- if (config -> log_to_file != INT_MIN )
139- fprintf (out , "log = %d \n" , config -> log_to_file );
140- if (config -> log_level != INT_MIN )
141- fprintf (out , "log-level = %s\n" , deparse_log_level (config -> log_level ));
147+ if (config -> log_level_console != INT_MIN )
148+ fprintf (out , "log-level-console = %s \n" , deparse_log_level ( config -> log_level_console ) );
149+ if (config -> log_level_file != INT_MIN )
150+ fprintf (out , "log-level-file = %s\n" , deparse_log_level (config -> log_level_file ));
142151 if (config -> log_filename )
143152 fprintf (out , "log-filename = %s\n" , config -> log_filename );
144153 if (config -> error_log_filename )
145154 fprintf (out , "error-log-filename = %s\n" , config -> error_log_filename );
146155 if (config -> log_directory )
147156 fprintf (out , "log-directory = %s\n" , config -> log_directory );
157+
158+ /*
159+ * Convert values from base unit
160+ */
148161 if (config -> log_rotation_size )
149- fprintf (out , "log-rotation-size = %d\n" , config -> log_rotation_size );
162+ {
163+ convert_from_base_unit_u (config -> log_rotation_size , OPTION_UNIT_KB ,
164+ & res , & unit );
165+ fprintf (out , "log-rotation-size = " UINT64_FORMAT "%s\n" , res , unit );
166+ }
150167 if (config -> log_rotation_age )
151- fprintf (out , "log-rotation-age = %d\n" , config -> log_rotation_age );
168+ {
169+ convert_from_base_unit_u (config -> log_rotation_age , OPTION_UNIT_S ,
170+ & res , & unit );
171+ fprintf (out , "log-rotation-age = " UINT64_FORMAT "%s\n" , res , unit );
172+ }
152173
153174 fprintf (out , "#Retention parameters:\n" );
154175 if (config -> retention_redundancy )
@@ -198,13 +219,13 @@ readBackupCatalogConfigFile(void)
198219 { 'f' , 0 , "compress-algorithm" , opt_compress_alg , SOURCE_CMDLINE },
199220 { 'u' , 0 , "compress-level" , & (config -> compress_level ), SOURCE_CMDLINE },
200221 /* logging options */
201- { 'b ' , 0 , "log" , & ( config -> log_to_file ) , SOURCE_CMDLINE },
202- { 'f' , 0 , "log-level" , opt_log_level , SOURCE_CMDLINE },
222+ { 'f ' , 0 , "log-level-console " , opt_log_level_console , SOURCE_CMDLINE },
223+ { 'f' , 0 , "log-level-file " , opt_log_level_file , SOURCE_CMDLINE },
203224 { 's' , 0 , "log-filename" , & (config -> log_filename ), SOURCE_CMDLINE },
204225 { 's' , 0 , "error-log-filename" , & (config -> error_log_filename ), SOURCE_CMDLINE },
205226 { 's' , 0 , "log-directory" , & (config -> log_directory ), SOURCE_CMDLINE },
206- { 'u' , 0 , "log-rotation-size" , & (config -> log_rotation_size ), SOURCE_CMDLINE },
207- { 'u' , 0 , "log-rotation-age" , & (config -> log_rotation_age ), SOURCE_CMDLINE },
227+ { 'u' , 0 , "log-rotation-size" , & (config -> log_rotation_size ), SOURCE_CMDLINE , SOURCE_DEFAULT , OPTION_UNIT_KB },
228+ { 'u' , 0 , "log-rotation-age" , & (config -> log_rotation_age ), SOURCE_CMDLINE , SOURCE_DEFAULT , OPTION_UNIT_S },
208229 /* connection options */
209230 { 's' , 0 , "pgdata" , & (config -> pgdata ), SOURCE_FILE_STRICT },
210231 { 's' , 0 , "pgdatabase" , & (config -> pgdatabase ), SOURCE_FILE_STRICT },
@@ -216,7 +237,7 @@ readBackupCatalogConfigFile(void)
216237 { 's' , 0 , "master-port" , & (config -> master_port ), SOURCE_FILE_STRICT },
217238 { 's' , 0 , "master-db" , & (config -> master_db ), SOURCE_FILE_STRICT },
218239 { 's' , 0 , "master-user" , & (config -> master_user ), SOURCE_FILE_STRICT },
219- { 'u' , 0 , "replica-timeout" , & (config -> replica_timeout ), SOURCE_CMDLINE },
240+ { 'u' , 0 , "replica-timeout" , & (config -> replica_timeout ), SOURCE_CMDLINE , SOURCE_DEFAULT , OPTION_UNIT_S },
220241 /* other options */
221242 { 'U' , 0 , "system-identifier" , & (config -> system_identifier ), SOURCE_FILE_STRICT },
222243 {0 }
@@ -234,9 +255,15 @@ readBackupCatalogConfigFile(void)
234255}
235256
236257static void
237- opt_log_level (pgut_option * opt , const char * arg )
258+ opt_log_level_console (pgut_option * opt , const char * arg )
259+ {
260+ cur_config -> log_level_console = parse_log_level (arg );
261+ }
262+
263+ static void
264+ opt_log_level_file (pgut_option * opt , const char * arg )
238265{
239- cur_config -> log_level = parse_log_level (arg );
266+ cur_config -> log_level_file = parse_log_level (arg );
240267}
241268
242269static void
0 commit comments