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

Commit9917514

Browse files
committed
Improve common/logging.c's support for multiple verbosity levels.
Instead of hard-wiring specific verbosity levels into the optionprocessing of client applications, invent pg_logging_increase_verbosity()and encourage clients to implement --verbose by calling that. Then,the common convention that more -v's gets you more verbosity just works.In particular, this allows resurrection of the debug-grade messages thathave long existed in pg_dump and its siblings. They were unreachablebefore this commit due to lack of a way to select PG_LOG_DEBUG logginglevel. (It appears that they may have been unreachable for some timebefore common/logging.c was introduced, too, so I'm not specificallyblamingcc8d415 for the oversight. One reason for thinking that isthat it's now apparent that _allocAH()'s message needs a null-pointerguard. Testing might have failed to reveal that before96bf88d.)Discussion:https://postgr.es/m/1173106.1600116625@sss.pgh.pa.us
1 parentb7f2dd9 commit9917514

File tree

12 files changed

+38
-9
lines changed

12 files changed

+38
-9
lines changed

‎doc/src/sgml/ref/pg_dump.sgml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ PostgreSQL documentation
594594
<application>pg_dump</application> to output detailed object
595595
comments and start/stop times to the dump file, and progress
596596
messages to standard error.
597+
Repeating the option causes additional debug-level messages
598+
to appear on standard error.
597599
</para>
598600
</listitem>
599601
</varlistentry>

‎doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ PostgreSQL documentation
202202
Specifies verbose mode. This will cause
203203
<application>pg_dumpall</application> to output start/stop
204204
times to the dump file, and progress messages to standard error.
205-
It will also enable verbose output in <application>pg_dump</application>.
205+
Repeating the option causes additional debug-level messages
206+
to appear on standard error.
207+
The option is also passed down to <application>pg_dump</application>.
206208
</para>
207209
</listitem>
208210
</varlistentry>

‎doc/src/sgml/ref/pg_restore.sgml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,12 @@ PostgreSQL documentation
483483
<term><option>--verbose</option></term>
484484
<listitem>
485485
<para>
486-
Specifies verbose mode.
486+
Specifies verbose mode. This will cause
487+
<application>pg_restore</application> to output detailed object
488+
comments and start/stop times to the output file, and progress
489+
messages to standard error.
490+
Repeating the option causes additional debug-level messages
491+
to appear on standard error.
487492
</para>
488493
</listitem>
489494
</varlistentry>

‎src/bin/pg_archivecleanup/pg_archivecleanup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ main(int argc, char **argv)
302302
switch (c)
303303
{
304304
case'd':/* Debug mode */
305-
pg_logging_set_level(PG_LOG_DEBUG);
305+
pg_logging_increase_verbosity();
306306
break;
307307
case'n':/* Dry-Run mode */
308308
dryrun= true;

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,8 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
22782278
{
22792279
ArchiveHandle*AH;
22802280

2281-
pg_log_debug("allocating AH for %s, format %d",FileSpec,fmt);
2281+
pg_log_debug("allocating AH for %s, format %d",
2282+
FileSpec ?FileSpec :"(stdio)",fmt);
22822283

22832284
AH= (ArchiveHandle*)pg_malloc0(sizeof(ArchiveHandle));
22842285

‎src/bin/pg_dump/pg_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ main(int argc, char **argv)
512512

513513
case 'v':/* verbose */
514514
g_verbose = true;
515-
pg_logging_set_level(PG_LOG_INFO);
515+
pg_logging_increase_verbosity();
516516
break;
517517

518518
case 'w':

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ main(int argc, char *argv[])
283283

284284
case'v':
285285
verbose= true;
286-
pg_logging_set_level(PG_LOG_INFO);
286+
pg_logging_increase_verbosity();
287287
appendPQExpBufferStr(pgdumpopts," -v");
288288
break;
289289

‎src/bin/pg_dump/pg_restore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ main(int argc, char **argv)
245245

246246
case'v':/* verbose */
247247
opts->verbose=1;
248-
pg_logging_set_level(PG_LOG_INFO);
248+
pg_logging_increase_verbosity();
249249
break;
250250

251251
case'w':

‎src/bin/pg_rewind/pg_rewind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ main(int argc, char **argv)
181181

182182
case3:
183183
debug= true;
184-
pg_logging_set_level(PG_LOG_DEBUG);
184+
pg_logging_increase_verbosity();
185185
break;
186186

187187
case'D':/* -D or --target-pgdata */

‎src/bin/pgbench/pgbench.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5522,7 +5522,7 @@ main(int argc, char **argv)
55225522
pgport=pg_strdup(optarg);
55235523
break;
55245524
case'd':
5525-
pg_logging_set_level(PG_LOG_DEBUG);
5525+
pg_logging_increase_verbosity();
55265526
break;
55275527
case'c':
55285528
benchmarking_option_set= true;

‎src/common/logging.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,30 @@ pg_logging_config(int new_flags)
157157
log_flags=new_flags;
158158
}
159159

160+
/*
161+
* pg_logging_init sets the default log level to INFO. Programs that prefer
162+
* a different default should use this to set it, immediately afterward.
163+
*/
160164
void
161165
pg_logging_set_level(enumpg_log_levelnew_level)
162166
{
163167
__pg_log_level=new_level;
164168
}
165169

170+
/*
171+
* Command line switches such as --verbose should invoke this.
172+
*/
173+
void
174+
pg_logging_increase_verbosity(void)
175+
{
176+
/*
177+
* The enum values are chosen such that we have to decrease __pg_log_level
178+
* in order to become more verbose.
179+
*/
180+
if (__pg_log_level>PG_LOG_NOTSET+1)
181+
__pg_log_level--;
182+
}
183+
166184
void
167185
pg_logging_set_pre_callback(void (*cb) (void))
168186
{

‎src/include/common/logging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ extern enum pg_log_level __pg_log_level;
6666
voidpg_logging_init(constchar*argv0);
6767
voidpg_logging_config(intnew_flags);
6868
voidpg_logging_set_level(enumpg_log_levelnew_level);
69+
voidpg_logging_increase_verbosity(void);
6970
voidpg_logging_set_pre_callback(void (*cb) (void));
7071
voidpg_logging_set_locus_callback(void (*cb) (constchar**filename,uint64*lineno));
7172

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp