]> git.ipfire.org Git - zone-sync.git/commitdiff
main: Add a --quiet flag for less logging
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 May 2026 16:16:44 +0000 (16:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 May 2026 16:16:44 +0000 (16:16 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
main.c

diff --git a/main.c b/main.c
index c492b2d99d9cec102dc52375cc9e7489300895c5..c391796b94a553b704d0843fe1a479fed411d89c 100644 (file)
--- 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;