From: Marko Kreen Date: Fri, 17 Aug 2007 21:04:20 +0000 (+0000) Subject: -q switch to turn off stdout usage X-Git-Tag: pgbouncer_1_1~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63ab7b8cf48b218279fa5a4e5524fc036ae7bfc0;p=pgbouncer -q switch to turn off stdout usage --- diff --git a/src/bouncer.h b/src/bouncer.h index f140538..0ed9160 100644 --- a/src/bouncer.h +++ b/src/bouncer.h @@ -257,6 +257,7 @@ struct PgSocket { /* main.c */ extern int cf_verbose; extern int cf_daemon; +extern int cf_quiet; extern char *cf_unix_socket_dir; extern char *cf_listen_addr; diff --git a/src/main.c b/src/main.c index 7cae3b5..ea9d64a 100644 --- a/src/main.c +++ b/src/main.c @@ -33,7 +33,7 @@ static bool set_auth(ConfElem *elem, const char *val, PgSocket *console); static const char *get_auth(ConfElem *elem); static const char *usage_str = -"usage: pgbouncer [-d] [-R] [-v] [-h|-V] config.ini\n"; +"usage: pgbouncer [-d] [-R] [-q] [-v] [-h|-V] config.ini\n"; static void usage(int err) { @@ -45,6 +45,7 @@ static void usage(int err) * configuration storage */ +int cf_quiet = 0; /* if set, no log is printed to stdout/err */ int cf_verbose = 0; int cf_daemon = 0; int cf_pause_mode = P_NONE; @@ -325,6 +326,9 @@ static void go_daemon(void) if (!cf_pidfile) fatal("daemon needs pidfile configured"); + /* dont log to stdout anymore */ + cf_quiet = 1; + /* just in case close all files */ for (fd = 3; fd < OPEN_MAX; fd++) close(fd); @@ -439,7 +443,7 @@ int main(int argc, char *argv[]) int c; /* parse cmdline */ - while ((c = getopt(argc, argv, "vhdVR")) != EOF) { + while ((c = getopt(argc, argv, "avhdVR")) != EOF) { switch (c) { case 'R': cf_reboot = 1; @@ -453,6 +457,9 @@ int main(int argc, char *argv[]) case 'd': cf_daemon = 1; break; + case 'q': + cf_quiet = 1; + break; case 'h': default: usage(1); diff --git a/src/util.c b/src/util.c index 0db3238..9f9aa84 100644 --- a/src/util.c +++ b/src/util.c @@ -60,7 +60,7 @@ static void _log_write(const char *pfx, const char *msg) safe_close(fd); } } - if (!cf_daemon) + if (!cf_quiet) fprintf(stderr, "%s", buf); }