Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf94c5ab

Browse files
author
Michael Paquier
committed
Sanitize logging facility
--debug and --verbose had actually the same meaning as they were aimedat giving to the user information regarding how the process is running,hence both options are merged into --verbose and use elog(LOG) to decideif a given message should be printed out depending on the verbosity ofthe call. This makes a couple of routines more readable as they do notdepend on any boolean checks.The "_()" have been removed from the code, those are aimed at being usedfor translation but having them mandatorily in each log message is justuseless noise. If needed, pgut.c should be updated in consequence tohave a more portable facility.At the same time this commit takes care of putting into correct shapesome code paths more in-line with PostgreSQL policy. There are surelymore of this kind of ugly stuff but at this stage things are more simpleand more manageable.
1 parent3ac6d13 commitf94c5ab

File tree

18 files changed

+300
-337
lines changed

18 files changed

+300
-337
lines changed

‎backup.c

Lines changed: 70 additions & 90 deletions
Large diffs are not rendered by default.

‎catalog.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ catalog_lock(void)
4141
lock_fd=open(id_path,O_RDWR);
4242
if (lock_fd==-1)
4343
elog(errno==ENOENT ?ERROR_CORRUPTED :ERROR_SYSTEM,
44-
_("can't open file \"%s\": %s"),id_path,strerror(errno));
44+
"cannot open file \"%s\": %s",id_path,strerror(errno));
4545

4646
ret=flock(lock_fd,LOCK_EX |LOCK_NB);/* non-blocking */
4747
if (ret==-1)
@@ -55,7 +55,7 @@ catalog_lock(void)
5555
{
5656
interrno_tmp=errno;
5757
close(lock_fd);
58-
elog(ERROR_SYSTEM,_("can't lock file \"%s\": %s"),id_path,
58+
elog(ERROR_SYSTEM,"cannot lock file \"%s\": %s",id_path,
5959
strerror(errno_tmp));
6060
}
6161
}
@@ -147,7 +147,7 @@ catalog_get_backup_list(const pgBackupRange *range)
147147
date_dir=opendir(backup_path);
148148
if (date_dir==NULL)
149149
{
150-
elog(WARNING,_("can't open directory \"%s\": %s"),backup_path,
150+
elog(WARNING,"cannot open directory \"%s\": %s",backup_path,
151151
strerror(errno));
152152
gotoerr_proc;
153153
}
@@ -175,7 +175,7 @@ catalog_get_backup_list(const pgBackupRange *range)
175175
time_dir=opendir(date_path);
176176
if (time_dir==NULL)
177177
{
178-
elog(WARNING,_("can't open directory \"%s\": %s"),
178+
elog(WARNING,"cannot open directory \"%s\": %s",
179179
date_ent->d_name,strerror(errno));
180180
gotoerr_proc;
181181
}
@@ -206,7 +206,7 @@ catalog_get_backup_list(const pgBackupRange *range)
206206
}
207207
if (errno&&errno!=ENOENT)
208208
{
209-
elog(WARNING,_("can't read date directory \"%s\": %s"),
209+
elog(WARNING,"cannot read date directory \"%s\": %s",
210210
date_ent->d_name,strerror(errno));
211211
gotoerr_proc;
212212
}
@@ -215,7 +215,7 @@ catalog_get_backup_list(const pgBackupRange *range)
215215
}
216216
if (errno)
217217
{
218-
elog(WARNING,_("can't read backup root directory \"%s\": %s"),
218+
elog(WARNING,"cannot read backup root directory \"%s\": %s",
219219
backup_path,strerror(errno));
220220
gotoerr_proc;
221221
}
@@ -298,7 +298,6 @@ pgBackupWriteConfigSection(FILE *out, pgBackup *backup)
298298
staticconstchar*modes[]= {"","PAGE","FULL"};
299299

300300
fprintf(out,"# configuration\n");
301-
302301
fprintf(out,"BACKUP_MODE=%s\n",modes[backup->backup_mode]);
303302
}
304303

@@ -352,7 +351,7 @@ pgBackupWriteIni(pgBackup *backup)
352351
pgBackupGetPath(backup,ini_path,lengthof(ini_path),BACKUP_INI_FILE);
353352
fp=fopen(ini_path,"wt");
354353
if (fp==NULL)
355-
elog(ERROR_SYSTEM,_("can't open INI file \"%s\": %s"),ini_path,
354+
elog(ERROR_SYSTEM,"cannot open INI file \"%s\": %s",ini_path,
356355
strerror(errno));
357356

358357
/* configuration section */
@@ -396,9 +395,8 @@ catalog_read_ini(const char *path)
396395
{0 }
397396
};
398397

399-
if (access(path,F_OK)!=0){
398+
if (access(path,F_OK)!=0)
400399
returnNULL;
401-
}
402400

403401
backup=pgut_new(pgBackup);
404402
catalog_init_config(backup);
@@ -434,7 +432,7 @@ catalog_read_ini(const char *path)
434432
if (sscanf(start_lsn,"%X/%X",&xlogid,&xrecoff)==2)
435433
backup->start_lsn= (XLogRecPtr) ((uint64)xlogid <<32) |xrecoff;
436434
else
437-
elog(WARNING,_("invalid START_LSN \"%s\""),start_lsn);
435+
elog(WARNING,"invalid START_LSN \"%s\"",start_lsn);
438436
free(start_lsn);
439437
}
440438

@@ -446,7 +444,7 @@ catalog_read_ini(const char *path)
446444
if (sscanf(stop_lsn,"%X/%X",&xlogid,&xrecoff)==2)
447445
backup->stop_lsn= (XLogRecPtr) ((uint64)xlogid <<32) |xrecoff;
448446
else
449-
elog(WARNING,_("invalid STOP_LSN \"%s\""),stop_lsn);
447+
elog(WARNING,"invalid STOP_LSN \"%s\"",stop_lsn);
450448
free(stop_lsn);
451449
}
452450

@@ -467,7 +465,7 @@ catalog_read_ini(const char *path)
467465
elseif (strcmp(status,"CORRUPT")==0)
468466
backup->status=BACKUP_STATUS_CORRUPT;
469467
else
470-
elog(WARNING,_("invalid STATUS \"%s\""),status);
468+
elog(WARNING,"invalid STATUS \"%s\"",status);
471469
free(status);
472470
}
473471

@@ -491,7 +489,7 @@ parse_backup_mode(const char *value)
491489
returnBACKUP_MODE_DIFF_PAGE;
492490

493491
/* Backup mode is invalid, so leave with an error */
494-
elog(ERROR_ARGS,_("invalid backup-mode \"%s\""),value);
492+
elog(ERROR_ARGS,"invalid backup-mode \"%s\"",value);
495493
returnBACKUP_MODE_INVALID;
496494
}
497495

‎data.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ backup_data_file(const char *from_root, const char *to_root,
9696
if (errno==ENOENT)
9797
return false;
9898

99-
elog(ERROR_SYSTEM,_("can't open backup mode file \"%s\": %s"),
99+
elog(ERROR_SYSTEM,"cannot open backup mode file \"%s\": %s",
100100
file->path,strerror(errno));
101101
}
102102

@@ -110,7 +110,7 @@ backup_data_file(const char *from_root, const char *to_root,
110110
{
111111
interrno_tmp=errno;
112112
fclose(in);
113-
elog(ERROR_SYSTEM,_("can't open backup file \"%s\": %s"),
113+
elog(ERROR_SYSTEM,"cannot open backup file \"%s\": %s",
114114
to_path,strerror(errno_tmp));
115115
}
116116

@@ -160,7 +160,7 @@ backup_data_file(const char *from_root, const char *to_root,
160160
/* oops */
161161
fclose(in);
162162
fclose(out);
163-
elog(ERROR_SYSTEM,_("can't write at block %u of \"%s\": %s"),
163+
elog(ERROR_SYSTEM,"cannot write at block %u of \"%s\": %s",
164164
blknum,to_path,strerror(errno_tmp));
165165
}
166166

@@ -176,7 +176,7 @@ backup_data_file(const char *from_root, const char *to_root,
176176
{
177177
fclose(in);
178178
fclose(out);
179-
elog(ERROR_SYSTEM,_("can't read backup mode file \"%s\": %s"),
179+
elog(ERROR_SYSTEM,"cannot read backup mode file \"%s\": %s",
180180
file->path,strerror(errno_tmp));
181181
}
182182

@@ -206,7 +206,7 @@ backup_data_file(const char *from_root, const char *to_root,
206206
fclose(in);
207207
fclose(out);
208208
elog(ERROR_SYSTEM,
209-
_("can't write at block %u of \"%s\": %s"),
209+
"cannot write at block %u of \"%s\": %s",
210210
blknum,to_path,strerror(errno_tmp));
211211
}
212212
COMP_CRC32C(crc,&header,sizeof(header));
@@ -220,7 +220,7 @@ backup_data_file(const char *from_root, const char *to_root,
220220
/* oops */
221221
fclose(in);
222222
fclose(out);
223-
elog(ERROR_SYSTEM,_("can't write at block %u of \"%s\": %s"),
223+
elog(ERROR_SYSTEM,"cannot write at block %u of \"%s\": %s",
224224
blknum,to_path,strerror(errno_tmp));
225225
}
226226

@@ -239,7 +239,7 @@ backup_data_file(const char *from_root, const char *to_root,
239239
interrno_tmp=errno;
240240
fclose(in);
241241
fclose(out);
242-
elog(ERROR_SYSTEM,_("can't change mode of \"%s\": %s"),file->path,
242+
elog(ERROR_SYSTEM,"cannot change mode of \"%s\": %s",file->path,
243243
strerror(errno_tmp));
244244
}
245245

@@ -258,7 +258,7 @@ backup_data_file(const char *from_root, const char *to_root,
258258
if (file->write_size==0&&file->read_size>0)
259259
{
260260
if (remove(to_path)==-1)
261-
elog(ERROR_SYSTEM,_("can't remove file \"%s\": %s"),to_path,
261+
elog(ERROR_SYSTEM,"cannot remove file \"%s\": %s",to_path,
262262
strerror(errno));
263263
return false;
264264
}
@@ -296,7 +296,7 @@ restore_data_file(const char *from_root,
296296
in=fopen(file->path,"r");
297297
if (in==NULL)
298298
{
299-
elog(ERROR_SYSTEM,_("can't open backup file \"%s\": %s"),file->path,
299+
elog(ERROR_SYSTEM,"cannot open backup file \"%s\": %s",file->path,
300300
strerror(errno));
301301
}
302302

@@ -313,7 +313,7 @@ restore_data_file(const char *from_root,
313313
{
314314
interrno_tmp=errno;
315315
fclose(in);
316-
elog(ERROR_SYSTEM,_("can't open restore target file \"%s\": %s"),
316+
elog(ERROR_SYSTEM,"cannot open restore target file \"%s\": %s",
317317
to_path,strerror(errno_tmp));
318318
}
319319

@@ -334,20 +334,20 @@ restore_data_file(const char *from_root,
334334
elseif (read_len!=0&&feof(in))
335335
{
336336
elog(ERROR_CORRUPTED,
337-
_("odd size page found at block %u of \"%s\""),
337+
"odd size page found at block %u of \"%s\"",
338338
blknum,file->path);
339339
}
340340
else
341341
{
342-
elog(ERROR_SYSTEM,_("can't read block %u of \"%s\": %s"),
342+
elog(ERROR_SYSTEM,"cannot read block %u of \"%s\": %s",
343343
blknum,file->path,strerror(errno_tmp));
344344
}
345345
}
346346

347347
if (header.block<blknum||header.hole_offset>BLCKSZ||
348348
(int)header.hole_offset+ (int)header.hole_length>BLCKSZ)
349349
{
350-
elog(ERROR_CORRUPTED,_("backup is broken at block %u"),
350+
elog(ERROR_CORRUPTED,"backup is broken at block %u",
351351
blknum);
352352
}
353353

@@ -360,7 +360,7 @@ restore_data_file(const char *from_root,
360360
if (fread(page.data,1,header.hole_offset,in)!=header.hole_offset||
361361
fread(page.data+upper_offset,1,upper_length,in)!=upper_length)
362362
{
363-
elog(ERROR_SYSTEM,_("can't read block %u of \"%s\": %s"),
363+
elog(ERROR_SYSTEM,"cannot read block %u of \"%s\": %s",
364364
blknum,file->path,strerror(errno));
365365
}
366366

@@ -370,10 +370,10 @@ restore_data_file(const char *from_root,
370370
*/
371371
blknum=header.block;
372372
if (fseek(out,blknum*BLCKSZ,SEEK_SET)<0)
373-
elog(ERROR_SYSTEM,_("can't seek block %u of \"%s\": %s"),
373+
elog(ERROR_SYSTEM,"cannot seek block %u of \"%s\": %s",
374374
blknum,to_path,strerror(errno));
375375
if (fwrite(page.data,1,sizeof(page),out)!=sizeof(page))
376-
elog(ERROR_SYSTEM,_("can't write block %u of \"%s\": %s"),
376+
elog(ERROR_SYSTEM,"cannot write block %u of \"%s\": %s",
377377
blknum,file->path,strerror(errno));
378378
}
379379

@@ -383,7 +383,7 @@ restore_data_file(const char *from_root,
383383
interrno_tmp=errno;
384384
fclose(in);
385385
fclose(out);
386-
elog(ERROR_SYSTEM,_("can't change mode of \"%s\": %s"),to_path,
386+
elog(ERROR_SYSTEM,"cannot change mode of \"%s\": %s",to_path,
387387
strerror(errno_tmp));
388388
}
389389

@@ -420,7 +420,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
420420
if (errno==ENOENT)
421421
return false;
422422

423-
elog(ERROR_SYSTEM,_("can't open source file \"%s\": %s"),file->path,
423+
elog(ERROR_SYSTEM,"cannot open source file \"%s\": %s",file->path,
424424
strerror(errno));
425425
}
426426

@@ -434,7 +434,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
434434
{
435435
interrno_tmp=errno;
436436
fclose(in);
437-
elog(ERROR_SYSTEM,_("can't open destination file \"%s\": %s"),
437+
elog(ERROR_SYSTEM,"cannot open destination file \"%s\": %s",
438438
to_path,strerror(errno_tmp));
439439
}
440440

@@ -443,7 +443,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
443443
{
444444
fclose(in);
445445
fclose(out);
446-
elog(ERROR_SYSTEM,_("can't stat \"%s\": %s"),file->path,
446+
elog(ERROR_SYSTEM,"cannot stat \"%s\": %s",file->path,
447447
strerror(errno));
448448
}
449449

@@ -459,7 +459,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
459459
/* oops */
460460
fclose(in);
461461
fclose(out);
462-
elog(ERROR_SYSTEM,_("can't write to \"%s\": %s"),to_path,
462+
elog(ERROR_SYSTEM,"cannot write to \"%s\": %s",to_path,
463463
strerror(errno_tmp));
464464
}
465465
/* update CRC */
@@ -474,7 +474,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
474474
{
475475
fclose(in);
476476
fclose(out);
477-
elog(ERROR_SYSTEM,_("can't read backup mode file \"%s\": %s"),
477+
elog(ERROR_SYSTEM,"cannot read backup mode file \"%s\": %s",
478478
file->path,strerror(errno_tmp));
479479
}
480480

@@ -487,7 +487,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
487487
/* oops */
488488
fclose(in);
489489
fclose(out);
490-
elog(ERROR_SYSTEM,_("can't write to \"%s\": %s"),to_path,
490+
elog(ERROR_SYSTEM,"cannot write to \"%s\": %s",to_path,
491491
strerror(errno_tmp));
492492
}
493493
/* update CRC */
@@ -507,7 +507,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
507507
errno_tmp=errno;
508508
fclose(in);
509509
fclose(out);
510-
elog(ERROR_SYSTEM,_("can't change mode of \"%s\": %s"),to_path,
510+
elog(ERROR_SYSTEM,"cannot change mode of \"%s\": %s",to_path,
511511
strerror(errno_tmp));
512512
}
513513

‎delete.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ do_delete(pgBackupRange *range)
2121

2222
/* DATE are always required */
2323
if (!pgBackupRangeIsValid(range))
24-
elog(ERROR_ARGS,_("required delete range option not specified: delete DATE"));
24+
elog(ERROR_ARGS,"required delete range option not specified: delete DATE");
2525

2626
/* Lock backup catalog */
2727
ret=catalog_lock();
2828
if (ret==-1)
29-
elog(ERROR_SYSTEM,_("can't lock backup catalog."));
29+
elog(ERROR_SYSTEM,"can't lock backup catalog.");
3030
elseif (ret==1)
3131
elog(ERROR_ALREADY_RUNNING,
32-
_("another pg_arman is running, stop delete."));
32+
"another pg_arman is running, stop delete.");
3333

3434
/* Get complete list of backup */
3535
backup_list=catalog_get_backup_list(NULL);
3636
if (!backup_list)
37-
elog(ERROR_SYSTEM,_("No backup list found, can't process any more."));
37+
elog(ERROR_SYSTEM,"No backup list found, can't process any more.");
3838

3939
/* Find backups to be deleted */
4040
for (i=0;i<parray_num(backup_list);i++)
@@ -46,7 +46,7 @@ do_delete(pgBackupRange *range)
4646
{
4747
/* check for interrupt */
4848
if (interrupted)
49-
elog(ERROR_INTERRUPTED,_("interrupted during delete backup"));
49+
elog(ERROR_INTERRUPTED,"interrupted during delete backup");
5050

5151
pgBackupDeleteFiles(backup);
5252
continue;
@@ -97,8 +97,8 @@ pgBackupDelete(int keep_generations, int keep_days)
9797
else
9898
snprintf(days_str,lengthof(days_str),"%d",keep_days);
9999

100-
printf(_("delete old backups (generations=%s, days=%s)\n"),
101-
generations_str,days_str);
100+
elog(LOG,"deleted old backups (generations=%s, days=%s)\n",
101+
generations_str,days_str);
102102
}
103103

104104
/* Leave if an infinite generation of backups is kept */
@@ -181,7 +181,7 @@ pgBackupDeleteFiles(pgBackup *backup)
181181

182182
time2iso(timestamp,lengthof(timestamp),backup->start_time);
183183

184-
elog(INFO,_("delete: %s"),timestamp);
184+
elog(INFO,"delete: %s",timestamp);
185185

186186
/*
187187
* update STATUS to BACKUP_STATUS_DELETING in preparation for the case which
@@ -205,15 +205,15 @@ pgBackupDeleteFiles(pgBackup *backup)
205205
pgFile*file= (pgFile*)parray_get(files,i);
206206

207207
/* print progress */
208-
elog(LOG,_("delete file(%d/%lu) \"%s\"\n"),i+1,
208+
elog(LOG,"delete file(%d/%lu) \"%s\"",i+1,
209209
(unsigned long)parray_num(files),file->path);
210210

211211
/* skip actual deletion in check mode */
212212
if (!check)
213213
{
214214
if (remove(file->path))
215215
{
216-
elog(WARNING,_("can't remove \"%s\": %s"),file->path,
216+
elog(WARNING,"can't remove \"%s\": %s",file->path,
217217
strerror(errno));
218218
parray_walk(files,pgFileFree);
219219
parray_free(files);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp