diff --git a/src/knot/other/log.c b/src/knot/other/log.c index 8c8b668d84464a9263aa25223cc0d8211332f26e..5374470a729e337399ad474509747e617c85a642 100644 --- a/src/knot/other/log.c +++ b/src/knot/other/log.c @@ -187,7 +187,7 @@ static int _log_msg(logsrc_t src, int level, const char *msg) // Syslog if (facility_levels(f, src) & level) { - syslog(level, msg, ""); + syslog(level, "%s", msg); ret = 1; // To prevent considering the message as ignored. } @@ -206,7 +206,7 @@ static int _log_msg(logsrc_t src, int level, const char *msg) } // Print - ret = fprintf(stream, msg, ""); + ret = fprintf(stream, "%s", msg); if (stream == stdout) { fflush(stream); } @@ -222,6 +222,18 @@ static int _log_msg(logsrc_t src, int level, const char *msg) int log_msg(logsrc_t src, int level, const char *msg, ...) { + /* Prefix error level. */ + switch (level) { + case LOG_DEBUG: break; + case LOG_INFO: break; + case LOG_NOTICE: _log_msg(src, level, "notice: "); break; + case LOG_WARNING: _log_msg(src, level, "warning: "); break; + case LOG_ERR: _log_msg(src, level, "error: "); break; + case LOG_FATAL: _log_msg(src, level, "fatal: "); break; + default: break; + } + + /* Compile log message. */ int ret = 0; char buf[2048]; va_list ap; @@ -229,6 +241,7 @@ int log_msg(logsrc_t src, int level, const char *msg, ...) ret = vsnprintf(buf, sizeof(buf) - 1, msg, ap); va_end(ap); + /* Send to logging facilities. */ if (ret > 0) { ret = _log_msg(src, level, buf); } diff --git a/src/knot/server/server.c b/src/knot/server/server.c index 965e1ae26551720b14206cdaa87253b0994921ae..c9b37c98ba142cc353babef99fd53b07ec94d6a6 100644 --- a/src/knot/server/server.c +++ b/src/knot/server/server.c @@ -340,9 +340,9 @@ static int server_load_zone(server_t *server, const char *origin, const char *db // Check if the db is up-to-date if (dnslib_zload_needs_update(zl)) { - log_server_warning("Zone file for '%s' " - "has changed, it is recommended to " - "recompile it.\n", + log_server_warning("Database for zone '%s' " + "is not up-to-date. " + "Please recompile.\n", origin); } @@ -528,14 +528,13 @@ int server_start(server_t *server, const char **filenames, uint zones) //!stat - // Load zones from config + /* Load zones from config. */ node *n = 0; int zones_loaded = 0; WALK_LIST (n, conf()->zones) { - // Fetch zone conf_zone_t *z = (conf_zone_t*)n; - // Check if the source has changed + /* Attempt to read db header. */ zloader_t *zl = dnslib_zload_open(z->db); if (zl == NULL) { log_server_error("Zone source file for '%s' " @@ -545,8 +544,9 @@ int server_start(server_t *server, const char **filenames, uint zones) } assert(zl != NULL); + /* Check zone source file against configured source. */ int src_changed = strcmp(z->file, zl->source) != 0; - if (src_changed || dnslib_zload_needs_update(zl)) { + if (src_changed) { log_server_warning("Zone source file for '%s' " "has changed, it is recommended to " "recompile it.\n", @@ -561,7 +561,7 @@ int server_start(server_t *server, const char **filenames, uint zones) pct += pct_incr; while (pct >= pct_threshold) { - log_server_info("..%d%s", pct_threshold, "%%"); + log_server_info("..%d%%", pct_threshold); pct_threshold += pct_step; } } @@ -577,7 +577,7 @@ int server_start(server_t *server, const char **filenames, uint zones) pct += pct_incr; while (pct >= pct_threshold) { - log_server_info("..%d%s", pct_threshold, "%%"); + log_server_info("..%d%%", pct_threshold); pct_threshold += pct_step; } }