From: Michael Tremer Date: Tue, 19 May 2026 16:16:44 +0000 (+0000) Subject: main: Add a --quiet flag for less logging X-Git-Tag: 0.0.1~1 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=f748a9cd5281ab853fb7edc52a3bb161e7d72d56;p=zone-sync.git main: Add a --quiet flag for less logging Signed-off-by: Michael Tremer --- diff --git a/main.c b/main.c index c492b2d..c391796 100644 --- a/main.c +++ b/main.c @@ -161,13 +161,21 @@ static void logger(int priority, const char* format, ...) { static void setup_logging(void) { isc_logconfig_t *logcfg = NULL; + int level = ISC_LOG_INFO; /* Create the log context and a default config */ isc_log_create(ctx.memctx, &ctx.log, &logcfg); - // Crank up debug verbosity - if (ctx.log_level == LOG_DEBUG) - isc_log_setdebuglevel(ctx.log, 6); // LOG_DEBUG); + // Translate the log level + switch (ctx.log_level) { + case LOG_DEBUG: + level = ISC_LOG_DEBUG(6); + break; + + case LOG_ERR: + level = ISC_LOG_ERROR; + break; + } /* Define a channel that writes everything to stderr */ isc_logdestination_t dest = { @@ -182,7 +190,7 @@ static void setup_logging(void) { logcfg, "stderr", /* channel name */ ISC_LOG_TOFILEDESC, /* destination type */ - ISC_LOG_DYNAMIC, /* level — DYNAMIC follows setdebuglevel */ + level, &dest, 0); @@ -578,13 +586,15 @@ static const char* args_doc = "ZONE [ZONE...]"; enum { OPT_DEBUG = 1, - OPT_PATH = 2, - OPT_PRIMARY = 3, - OPT_SECURE = 4, + OPT_QUIET = 2, + OPT_PATH = 3, + OPT_PRIMARY = 4, + OPT_SECURE = 5, }; static struct argp_option options[] = { { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 }, + { "quiet", OPT_QUIET, NULL, 0, "Run in quiet mode", 0 }, { "path", OPT_PATH, "PATH", 1, "Path where to store the zones", 0 }, { "primary", OPT_PRIMARY, "HOSTNAME", 1, "The hostname of the primary to fetch from", 0 }, { "secure", OPT_SECURE , NULL, 0, "Use a secure transport to transfer the zone", 0 }, @@ -641,6 +651,10 @@ static error_t parse(int key, char* arg, struct argp_state* state) { ctx.log_level = LOG_DEBUG; break; + case OPT_QUIET: + ctx.log_level = LOG_ERR; + break; + case OPT_PATH: ctx.path = arg; break;