From 5d6d723a076c04dbba75f9eff4e8c2c611dee6bc Mon Sep 17 00:00:00 2001
From: Daniel Salzman <daniel.salzman@nic.cz>
Date: Mon, 16 Jun 2014 10:55:17 +0200
Subject: [PATCH] conf: remove 'answering' log category

---
 doc/reference.rst        |  1 -
 samples/knot.full.conf   |  1 -
 src/common/log.h         | 10 +---------
 src/knot/conf/cf-lex.l   |  8 +++++++-
 src/knot/conf/cf-parse.y |  4 ++--
 src/knot/ctl/remote.c    |  6 +++---
 6 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/doc/reference.rst b/doc/reference.rst
index cff1ac6e0b..ea9f277e56 100644
--- a/doc/reference.rst
+++ b/doc/reference.rst
@@ -1104,7 +1104,6 @@ Knot DNS allows user to choose from these logging categories:
 
 * ``server`` - Messages related to general operation of the server.
 * ``zone`` - Messages related to zones, zone parsing and loading.
-* ``answering`` - Messages regarding query processing and response creation.
 * ``any`` - All categories.
 
 .. _severity:
diff --git a/samples/knot.full.conf b/samples/knot.full.conf
index 52c408e8b7..3d9aab6561 100644
--- a/samples/knot.full.conf
+++ b/samples/knot.full.conf
@@ -412,7 +412,6 @@ zones {
 # Supported categories:
 #   server    - Messages related to general operation of the server.
 #   zone      - Messages related to zones, zone parsing and loading.
-#   answering - Messages regarding query processing and response creation.
 #   any       - All categories
 #
 # Default settings (in case there are no entries in 'log' section or the section
diff --git a/src/common/log.h b/src/common/log.h
index e14159e609..c83fdbfe97 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -54,8 +54,7 @@ typedef enum {
 /*! \brief Log sources (max. LOG_SRC_BITS bits). */
 typedef enum {
 	LOG_SERVER = 0, /*!< Server module. */
-	LOG_ANSWER = 1, /*!< Query answering module. */
-	LOG_ZONE   = 2, /*!< Zone manipulation module. */
+	LOG_ZONE   = 1, /*!< Zone manipulation module. */
 	LOG_ANY    = 7  /*!< Any module. */
 } logsrc_t;
 
@@ -154,13 +153,6 @@ void hex_log(int source, const char *data, int length);
 #define log_server_info(msg...)      log_msg(LOG_SERVER, LOG_INFO, msg)
 #define log_server_debug(msg...)     log_msg(LOG_SERVER, LOG_DEBUG, msg)
 
-#define log_answer_fatal(msg...)     log_msg(LOG_ANSWER, LOG_CRIT, msg)
-#define log_answer_error(msg...)     log_msg(LOG_ANSWER, LOG_ERR, msg)
-#define log_answer_warning(msg...)   log_msg(LOG_ANSWER, LOG_WARNING, msg)
-#define log_answer_notice(msg...)    log_msg(LOG_ANSWER, LOG_NOTICE, msg)
-#define log_answer_info(msg...)      log_msg(LOG_ANSWER, LOG_INFO, msg)
-#define log_answer_debug(msg...)     log_msg(LOG_ANSWER, LOG_DEBUG, msg)
-
 #define log_zone_fatal(msg...)       log_msg(LOG_ZONE, LOG_CRIT, msg)
 #define log_zone_error(msg...)       log_msg(LOG_ZONE, LOG_ERR, msg)
 #define log_zone_warning(msg...)     log_msg(LOG_ZONE, LOG_WARNING, msg)
diff --git a/src/knot/conf/cf-lex.l b/src/knot/conf/cf-lex.l
index 0bbeb88199..b3b71f821c 100644
--- a/src/knot/conf/cf-lex.l
+++ b/src/knot/conf/cf-lex.l
@@ -149,7 +149,13 @@ log             { lval.t = yytext; return LOG; }
 
 any { lval.t = yytext; lval.i = LOG_ANY; return LOG_SRC; }
 server { lval.t = yytext; lval.i = LOG_SERVER; return LOG_SRC; }
-answering { lval.t = yytext; lval.i = LOG_ANSWER; return LOG_SRC; }
+answering {
+	lval.t = yytext;
+	lval.i = LOG_SERVER;
+	fprintf(stderr, "Warning: log category 'answering' is no longer "
+	                "supported. Using 'server' instead.\n");
+	return LOG_SRC;
+}
 zone { lval.t = yytext; lval.i = LOG_ZONE; return LOG_SRC; }
 stdout { lval.t = yytext; lval.i = LOGT_STDOUT; return LOG_DEST; }
 stderr { lval.t = yytext; lval.i = LOGT_STDERR; return LOG_DEST; }
diff --git a/src/knot/conf/cf-parse.y b/src/knot/conf/cf-parse.y
index 25012dd3c9..6791d71654 100644
--- a/src/knot/conf/cf-parse.y
+++ b/src/knot/conf/cf-parse.y
@@ -981,11 +981,11 @@ log_prios_start: {
 
 log_prios:
    log_prios_start
- | log_prios LOG_LEVEL ',' { this_logmap->prios |= $2.i; }
- | log_prios LOG_LEVEL ';' { this_logmap->prios |= $2.i;
+ | log_prios LOG_LEVEL ',' { this_logmap->prios |= $2.i;
 	fprintf(stderr, "Warning: more log severities per statement is deprecated. "
 	                "Using the least serious one.\n");
  }
+ | log_prios LOG_LEVEL ';' { this_logmap->prios |= $2.i; }
  ;
 
 log_src:
diff --git a/src/knot/ctl/remote.c b/src/knot/ctl/remote.c
index edd04a0366..4bd19d80de 100644
--- a/src/knot/ctl/remote.c
+++ b/src/knot/ctl/remote.c
@@ -648,7 +648,7 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
 	assert(tsig_rcode != NULL);
 
 	if (query->tsig_rr == NULL) {
-		log_answer_info("TSIG key required, but not in query - REFUSED.\n");
+		log_server_info("TSIG key required, but not in query - REFUSED.\n");
 		*rcode = KNOT_RCODE_REFUSED;
 		return KNOT_TSIG_EBADKEY;
 	}
@@ -658,7 +658,7 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
 	 */
 	knot_tsig_algorithm_t alg = tsig_rdata_alg(query->tsig_rr);
 	if (knot_tsig_digest_length(alg) == 0) {
-		log_answer_info("Unsupported digest algorithm "
+		log_server_info("Unsupported digest algorithm "
 		                "requested, treating as bad key\n");
 		/*! \todo [TSIG] It is unclear from RFC if I
 		 *               should treat is as a bad key
@@ -702,7 +702,7 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
 
 	if (mac_len > digest_max_size) {
 		*rcode = KNOT_RCODE_FORMERR;
-		log_answer_info("MAC length %zu exceeds digest "
+		log_server_info("MAC length %zu exceeds digest "
 		                "maximum size %zu\n", mac_len, digest_max_size);
 		return KNOT_EMALF;
 	} else {
-- 
GitLab