9
9
10
10
#include "pg_probackup.h"
11
11
12
+ static void opt_log_level (pgut_option * opt ,const char * arg );
13
+
14
+ static pgBackupConfig * cur_config = NULL ;
15
+
12
16
/* Set configure options */
13
17
int
14
18
do_configure (bool show_only )
@@ -25,6 +29,19 @@ do_configure(bool show_only)
25
29
if (username )
26
30
config -> pguser = username ;
27
31
32
+ if (log_level_defined )
33
+ config -> log_level = log_level ;
34
+ if (log_filename )
35
+ config -> log_filename = log_filename ;
36
+ if (error_log_filename )
37
+ config -> error_log_filename = error_log_filename ;
38
+ if (log_directory )
39
+ config -> log_directory = log_directory ;
40
+ if (log_rotation_size )
41
+ config -> log_rotation_size = log_rotation_size ;
42
+ if (log_rotation_age )
43
+ config -> log_rotation_age = log_rotation_age ;
44
+
28
45
if (retention_redundancy )
29
46
config -> retention_redundancy = retention_redundancy ;
30
47
if (retention_window )
@@ -48,6 +65,13 @@ pgBackupConfigInit(pgBackupConfig *config)
48
65
config -> pgport = NULL ;
49
66
config -> pguser = NULL ;
50
67
68
+ config -> log_level = INT_MIN ;// INT_MIN means "undefined"
69
+ config -> log_filename = NULL ;
70
+ config -> error_log_filename = NULL ;
71
+ config -> log_directory = NULL ;
72
+ config -> log_rotation_size = 0 ;
73
+ config -> log_rotation_age = 0 ;
74
+
51
75
config -> retention_redundancy = 0 ;
52
76
config -> retention_window = 0 ;
53
77
}
@@ -69,6 +93,20 @@ writeBackupCatalogConfig(FILE *out, pgBackupConfig *config)
69
93
if (config -> pguser )
70
94
fprintf (out ,"PGUSER = %s\n" ,config -> pguser );
71
95
96
+ fprintf (out ,"#Logging parameters:\n" );
97
+ if (config -> log_level != INT_MIN )
98
+ fprintf (out ,"log-level = %s\n" ,deparse_log_level (config -> log_level ));
99
+ if (config -> log_filename )
100
+ fprintf (out ,"log-filename = %s\n" ,config -> log_filename );
101
+ if (config -> error_log_filename )
102
+ fprintf (out ,"error-log-filename = %s\n" ,config -> error_log_filename );
103
+ if (config -> log_directory )
104
+ fprintf (out ,"log-directory = %s\n" ,config -> log_directory );
105
+ if (config -> log_rotation_size )
106
+ fprintf (out ,"log-rotation-size = %d\n" ,config -> log_rotation_size );
107
+ if (config -> log_rotation_age )
108
+ fprintf (out ,"log-rotation-age = %d\n" ,config -> log_rotation_age );
109
+
72
110
fprintf (out ,"#Retention parameters:\n" );
73
111
if (config -> retention_redundancy )
74
112
fprintf (out ,"retention-redundancy = %u\n" ,config -> retention_redundancy );
@@ -107,12 +145,12 @@ readBackupCatalogConfigFile(void)
107
145
{'u' ,0 ,"retention-redundancy" ,& (config -> retention_redundancy ),SOURCE_FILE_STRICT },
108
146
{'u' ,0 ,"retention-window" ,& (config -> retention_window ),SOURCE_FILE_STRICT },
109
147
/* logging options */
110
- // { 'f', 40, "log-level",opt_log_level,SOURCE_CMDLINE },
111
- // { 's', 41, "log-filename",&log_filename,SOURCE_CMDLINE },
112
- // { 's', 42, "error-log-filename",&error_log_filename, SOURCE_CMDLINE },
113
- // { 's', 43, "log-directory",&log_directory,SOURCE_CMDLINE },
114
- // { 'u', 44, "log-rotation-size",&log_rotation_size,SOURCE_CMDLINE },
115
- // { 'u', 45, "log-rotation-age",&log_rotation_age,SOURCE_CMDLINE },
148
+ {'f' ,40 ,"log-level" ,opt_log_level ,SOURCE_CMDLINE },
149
+ {'s' ,41 ,"log-filename" ,& ( config -> log_filename ) ,SOURCE_CMDLINE },
150
+ {'s' ,42 ,"error-log-filename" ,& ( config -> error_log_filename ), SOURCE_CMDLINE },
151
+ {'s' ,43 ,"log-directory" ,& ( config -> log_directory ) ,SOURCE_CMDLINE },
152
+ {'u' ,44 ,"log-rotation-size" ,& ( config -> log_rotation_size ) ,SOURCE_CMDLINE },
153
+ {'u' ,45 ,"log-rotation-age" ,& ( config -> log_rotation_age ) ,SOURCE_CMDLINE },
116
154
/* connection options */
117
155
{'s' ,0 ,"pgdata" ,& (config -> pgdata ),SOURCE_FILE_STRICT },
118
156
{'s' ,0 ,"pgdatabase" ,& (config -> pgdatabase ),SOURCE_FILE_STRICT },
@@ -124,6 +162,8 @@ readBackupCatalogConfigFile(void)
124
162
{0 }
125
163
};
126
164
165
+ cur_config = config ;
166
+
127
167
join_path_components (path ,backup_path ,BACKUPS_DIR );
128
168
join_path_components (path ,backup_path ,BACKUP_CATALOG_CONF_FILE );
129
169
@@ -133,3 +173,9 @@ readBackupCatalogConfigFile(void)
133
173
return config ;
134
174
135
175
}
176
+
177
+ static void
178
+ opt_log_level (pgut_option * opt ,const char * arg )
179
+ {
180
+ cur_config -> log_level = parse_log_level (arg );
181
+ }