Commit e2c4b960 authored by Jan Včelák's avatar Jan Včelák 🚀

more log messages cleanup

parent 419d63fc
......@@ -482,7 +482,7 @@ int log_reconfigure(const struct conf_t *conf, void *data)
if (facility == LOGT_FILE) {
facility = log_open_file(log, facility_conf->file);
if (facility < 0) {
log_error("Failed to open logfile '%s'",
log_error("failed to open log, file '%s'",
facility_conf->file);
continue;
}
......
......@@ -563,7 +563,7 @@ static void log_command(const char *cmd, const remote_cmdargs_t* args)
}
}
log_info("remote command: '%s%s'", cmd, params);
log_info("remote control, received command '%s%s'", cmd, params);
}
int remote_answer(int sock, server_t *s, knot_pkt_t *pkt)
......@@ -789,7 +789,7 @@ int remote_process(server_t *s, conf_iface_t *ctl_if, int sock,
uint16_t ts_trc = 0;
uint64_t ts_tmsigned = 0;
if (match == NULL) {
log_warning("denied remote control for '%s', "
log_warning("remote control, denied '%s', "
"no matching ACL", addr_str);
remote_senderr(client, pkt->wire, pkt->size);
ret = KNOT_EACCES;
......@@ -801,7 +801,7 @@ int remote_process(server_t *s, conf_iface_t *ctl_if, int sock,
/* Check TSIG. */
if (tsig_key) {
if (pkt->tsig_rr == NULL) {
log_warning("denied remote control for '%s', "
log_warning("remote control, denied '%s', "
"key required", addr_str);
remote_senderr(client, pkt->wire, pkt->size);
ret = KNOT_EACCES;
......@@ -810,7 +810,7 @@ int remote_process(server_t *s, conf_iface_t *ctl_if, int sock,
ret = zones_verify_tsig_query(pkt, tsig_key, &ts_rc,
&ts_trc, &ts_tmsigned);
if (ret != KNOT_EOK) {
log_warning("denied remote control for '%s', "
log_warning("remote control, denied '%s', "
"key verification failed", addr_str);
remote_senderr(client, pkt->wire, pkt->size);
ret = KNOT_EACCES;
......
......@@ -215,7 +215,8 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
free(path);
if (ret != KNOT_EOK) {
log_zone_warning(zone_name, "DNSSEC, failed to load key '%s' (%s)",
log_zone_warning(zone_name, "DNSSEC, failed to load "
"key, file '%s' (%s)",
entry->d_name, knot_strerror(ret));
knot_free_key_params(&params);
continue;
......@@ -243,7 +244,7 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
nsec3_enabled)
) {
log_zone_notice(zone_name, "DNSSEC, ignoring key %5d, "
"file %s (incompatible algorithm)",
"file '%s' (incompatible algorithm)",
params.keytag, entry->d_name);
knot_free_key_params(&params);
free(key);
......@@ -252,7 +253,7 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
if (knot_get_zone_key(keys, params.keytag) != NULL) {
log_zone_notice(zone_name, "DNSSEC, ignoring key %5d, "
"file %s (duplicate keytag)",
"file '%s' (duplicate keytag)",
params.keytag, entry->d_name);
knot_free_key_params(&params);
free(key);
......@@ -262,7 +263,7 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
ret = knot_dnssec_key_from_params(&params, &key->dnssec_key);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, failed to process "
"key %5d, file %s (%s)",
"key %5d, file '%s' (%s)",
params.keytag, entry->d_name,
knot_strerror(ret));
knot_free_key_params(&params);
......@@ -270,7 +271,7 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
continue;
}
log_zone_info(zone_name, "DNSSEC, loaded key %5d, file %s, %s, %s, %s",
log_zone_info(zone_name, "DNSSEC, loaded key %5d, file '%s', %s, %s, %s",
params.keytag, entry->d_name,
key->is_ksk ? "KSK" : "ZSK",
key->is_active ? "active" : "inactive",
......
......@@ -286,8 +286,8 @@ static void rrl_log_state(const struct sockaddr_storage *ss, uint16_t flags, uin
what = "enters";
}
log_notice("address '%s' %s rate-limiting (class '%s')",
addr_str, what, rrl_clsstr(cls));
log_notice("rate-limiting, address '%s' class '%s' %s limiting",
addr_str, rrl_clsstr(cls), what);
#endif
}
......
......@@ -224,7 +224,7 @@ static int reconfigure_sockets(const struct conf_t *conf, server_t *s)
rem_node((node_t *)m);
} else {
sockaddr_tostr(&cfg_if->addr, addr_str, sizeof(addr_str));
log_info("binding to interface %s", addr_str);
log_info("binding to interface '%s'", addr_str);
/* Create new interface. */
m = malloc(sizeof(iface_t));
......@@ -538,7 +538,7 @@ static int reconfigure_rate_limits(const struct conf_t *conf, server_t *server)
if (conf->rrl < 1) {
log_info("rate limiting disabled");
} else {
log_info("rate limiting set to %u responses/sec",
log_info("rate limiting enabled, %u responses/sec",
conf->rrl);
}
rrl_setrate(server->rrl, conf->rrl);
......
......@@ -83,7 +83,7 @@ static enum fdset_sweep_state tcp_sweep(fdset_t *set, int i, void *data)
char addr_str[SOCKADDR_STRLEN] = {0};
sockaddr_tostr(&ss, addr_str, sizeof(addr_str));
log_notice("connection '%s' was terminated due to inactivity", addr_str);
log_notice("connection terminated due to inactivity, address '%s'", addr_str);
close(fd);
return FDSET_SWEEP;
}
......@@ -122,8 +122,8 @@ static int tcp_handle(tcp_context_t *tcp, int fd,
rcu_read_lock();
char addr_str[SOCKADDR_STRLEN] = {0};
sockaddr_tostr(&ss, addr_str, sizeof(addr_str));
log_warning("couldn't receive query from '%s' within "
"the time limit of %ds",
log_warning("connection timed out, address '%s', "
"timeout %d seconds",
addr_str, conf()->max_conn_idle);
rcu_read_unlock();
}
......@@ -172,10 +172,9 @@ int tcp_accept(int fd)
if (en == EMFILE || en == ENFILE ||
en == ENOBUFS || en == ENOMEM) {
int throttle = tcp_throttle();
log_error("throttling TCP connection pool for"
"%d seconds because of too many open "
"descriptors or lack of memory",
throttle);
log_error("throttling TCP connection pool for "
"%d seconds, too many allocated "
"resources", throttle);
sleep(throttle);
}
......@@ -190,8 +189,8 @@ int tcp_accept(int fd)
rcu_read_unlock();
tv.tv_usec = 0;
if (setsockopt(incoming, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
log_warning("couldn't set up TCP connection watchdog "
"timer for fd=%d", incoming);
log_warning("cannot set up TCP connection watchdog "
"timer, fd %d", incoming);
}
#endif
}
......
......@@ -99,7 +99,7 @@ static inline void udp_pps_sample(unsigned n, unsigned thr_id)
unsigned pps = __pps_rx;
memcpy(&__pps_t0, &__pps_t1, sizeof(struct timeval));
__pps_rx = 0;
log_server_info("RX rate %u p/s.\n", pps);
log_server_info("RX rate %u packets/s", pps);
}
}
}
......
......@@ -545,8 +545,8 @@ static int process_add_nsec3param(const zone_node_t *node,
if (node == NULL || !node_rrtype_exists(node, KNOT_RRTYPE_SOA)) {
// Ignore non-apex additions
char *owner = knot_dname_to_str(rr->owner);
log_warning("refusing to add NSEC3PARAM owned by '%s' to "
"non-apex node", owner);
log_warning("DDNS, refusing to add NSEC3PARAM to non-apex "
"node '%s'", owner);
free(owner);
return KNOT_EDENIED;
}
......@@ -556,8 +556,7 @@ static int process_add_nsec3param(const zone_node_t *node,
}
char *owner = knot_dname_to_str(rr->owner);
log_warning("refusing to add NSEC3PARAM owned by '%s', NSEC3PARAM "
"already present, remove it first", owner);
log_warning("DDNS, refusing to add second NSEC3PARAM to node '%s'", owner);
free(owner);
return KNOT_EOK;
......@@ -817,7 +816,7 @@ static int check_update(const knot_rrset_t *rrset, const knot_pkt_t *query,
if (knot_rrtype_is_ddns_forbidden(rrset->type)) {
*rcode = KNOT_RCODE_REFUSED;
log_warning("refusing to update DNSSEC-related record");
log_warning("DDNS, refusing to update DNSSEC-related record");
return KNOT_EDENIED;
}
......
......@@ -1364,8 +1364,8 @@ uint32_t zone_contents_next_serial(const zone_contents_t *zone, int policy)
/* If the new serial is 'lower' or equal than the new one, warn the user.*/
if (knot_serial_compare(old_serial, new_serial) >= 0) {
log_zone_warning(zone->apex->owner, "new serial will be lower "
"than the current one (%u -> %u)",
log_zone_warning(zone->apex->owner, "updated serial is lower "
"than current, serial %u -> %u",
old_serial, new_serial);
}
......
......@@ -174,7 +174,7 @@ static void log_error_from_node(err_handler_t *handler,
}
if (node == NULL) {
log_zone_warning(zone_name, "semantic check, warnings %d, error (%s)",
log_zone_warning(zone_name, "semantic check, %d warnings, error (%s)",
handler->errors[-error], error_messages[-error]);
return;
}
......@@ -1073,7 +1073,7 @@ void log_cyclic_errors_in_zone(err_handler_t *handler,
next_dname_size,
apex->owner);
if (next_dname == NULL) {
log_zone_warning(zone->apex->owner, "sematic check: "
log_zone_warning(zone->apex->owner, "sematic check, "
"could not create new dname");
return;
}
......
......@@ -168,14 +168,14 @@ int zone_load_post(zone_contents_t *contents, zone_t *zone, uint32_t *dnssec_ref
}
ret = zone_contents_create_diff(zone->contents, contents, &change);
if (ret == KNOT_ENODIFF) {
log_zone_warning(zone->name, "zone file changed, "
"but serial didn't, won't create "
"create journal entry");
log_zone_warning(zone->name, "cannot create journal "
"entry, zone file changed without "
"SOA serial update");
ret = KNOT_EOK;
} else if (ret == KNOT_ERANGE) {
log_zone_warning(zone->name, "zone file changed, "
"but serial is lower than before, "
"IXFR history will be lost");
log_zone_warning(zone->name, "IXFR history will be lost, "
"zone file changed with SOA serial "
"decreased");
ret = KNOT_EOK;
} else if (ret != KNOT_EOK) {
log_zone_error(zone->name, "failed to calculate "
......
......@@ -116,7 +116,7 @@ int zone_change_store(zone_t *zone, changeset_t *change)
int ret = journal_store_changeset(change, conf->ixfr_db, conf->ixfr_fslimit);
if (ret == KNOT_EBUSY) {
log_zone_notice(zone->name, "zone journal is full, flushing");
log_zone_notice(zone->name, "journal is full, flushing");
/* Transaction rolled back, journal released, we may flush. */
ret = zone_flush_journal(zone);
......
......@@ -38,21 +38,19 @@
#include "libknot/rdata.h"
#include "knot/zone/zone-dump.h"
#define ERROR(zone, fmt...) log_zone_error(zone, "zone loader, " fmt)
#define WARNING(zone, fmt...) log_zone_warning(zone, "zone loader, " fmt)
#define INFO(zone, fmt...) log_zone_info(zone, "zone loader, " fmt)
void process_error(zs_scanner_t *s)
{
zcreator_t *zc = s->data;
const knot_dname_t *zname = zc->z->apex->owner;
if (s->stop == true) {
log_zone_error(zname, "fatal error in zone file %s:%"PRIu64": %s, "
"stopping zone loading.",
s->file.name, s->line_counter,
zs_strerror(s->error_code));
} else {
log_zone_error(zname,"error in zone file %s:%" PRIu64 ": %s",
s->file.name, s->line_counter,
zs_strerror(s->error_code));
}
ERROR(zname, "%s in zone, file %s, line %"PRIu64" (%s)",
s->stop ? "fatal error" : "error",
s->file.name, s->line_counter,
zs_strerror(s->error_code));
}
static int add_rdata_to_rr(knot_rrset_t *rrset, const zs_scanner_t *scanner)
......@@ -67,8 +65,8 @@ static bool handle_err(zcreator_t *zc, const zone_node_t *node,
const knot_dname_t *zname = zc->z->apex->owner;
char *rrname = rr ? knot_dname_to_str(rr->owner) : NULL;
if (ret == KNOT_EOUTOFZONE) {
log_zone_warning(zname, "ignoring out-of-zone data for %s",
rrname ? rrname : "unknown");
WARNING(zname, "ignoring out-of-zone data, owner '%s'",
rrname ? rrname : "unknown");
free(rrname);
return true;
} else if (ret == KNOT_ETTL) {
......@@ -78,8 +76,8 @@ static bool handle_err(zcreator_t *zc, const zone_node_t *node,
// Fail if we're the master for this zone.
return !master;
} else {
log_zone_error(zname, "cannot process record %s, stopping",
rrname ? rrname : "unknown");
ERROR(zname, "failed to process record, owner '%s'",
rrname ? rrname : "unknown");
free(rrname);
return false;
}
......@@ -94,7 +92,7 @@ void log_ttl_error(const zone_contents_t *zone, const zone_node_t *node,
char info_str[64] = { '\0' };
char type_str[16] = { '\0' };
knot_rrtype_to_string(rr->type, type_str, sizeof(type_str));
int ret = snprintf(info_str, sizeof(info_str), "Record type: %s.",
int ret = snprintf(info_str, sizeof(info_str), "record type %s",
type_str);
if (ret <= 0 || ret >= sizeof(info_str)) {
*info_str = '\0';
......@@ -166,9 +164,9 @@ static void scanner_process(zs_scanner_t *scanner)
int ret = add_rdata_to_rr(&rr, scanner);
if (ret != KNOT_EOK) {
char *rr_name = knot_dname_to_str(rr.owner);
log_zone_error(zc->z->apex->owner, "file %s:%"PRIu64": "
"can't add RDATA for '%s'", scanner->file.name,
scanner->line_counter, rr_name);
const knot_dname_t *zname = zc->z->apex->owner;
ERROR(zname, "cannot add RDATA, file '%s', line %"PRIu64", owner '%s'",
scanner->file.name, scanner->line_counter, rr_name);
free(rr_name);
knot_dname_free(&owner, NULL);
zc->ret = ret;
......@@ -257,28 +255,25 @@ zone_contents_t *zonefile_load(zloader_t *loader)
assert(zc);
int ret = zs_scanner_parse_file(loader->scanner, loader->source);
if (ret != 0) {
log_zone_error(zname, "zone file '%s' could not be loaded (%s)",
loader->source, zs_strerror(ret));
ERROR(zname, "could not load zone, file '%s' (%s)",
loader->source, zs_strerror(ret));
goto fail;
}
if (zc->ret != KNOT_EOK) {
log_zone_error(zname, "zone file '%s' could not be loaded (%s)",
loader->source, knot_strerror(zc->ret));
ERROR(zname, "could not load zone, file '%s' (%s)",
loader->source, knot_strerror(zc->ret));
goto fail;
}
if (loader->scanner->error_counter > 0) {
log_zone_error(zname, "zone file '%s' could not be loaded due "
"to %"PRIu64" errors encountered",
loader->source,
loader->scanner->error_counter);
ERROR(zname, "could not load zone, file '%s', %"PRIu64"errors",
loader->source, loader->scanner->error_counter);
goto fail;
}
if (!node_rrtype_exists(loader->creator->z->apex, KNOT_RRTYPE_SOA)) {
log_zone_error(zname, "no SOA record in the zone file '%s'",
loader->source);
ERROR(zname, "no SOA record, file '%s'", loader->source);
goto fail;
}
......@@ -288,8 +283,8 @@ zone_contents_t *zonefile_load(zloader_t *loader)
int kret = zone_contents_adjust_full(zc->z,
&first_nsec3_node, &last_nsec3_node);
if (kret != KNOT_EOK) {
log_zone_error(zname, "failed to finalize zone contents (%s)",
knot_strerror(kret));
ERROR(zname, "failed to finalize zone contents (%s)",
knot_strerror(kret));
goto fail;
}
......@@ -311,7 +306,7 @@ zone_contents_t *zonefile_load(zloader_t *loader)
zone_do_sem_checks(zc->z, check_level,
&err_handler, first_nsec3_node,
last_nsec3_node);
log_zone_info(zname, "semantic checks completed");
INFO(zname, "semantic checks completed");
}
return zc->z;
......@@ -373,15 +368,15 @@ int zonefile_write(const char *path, zone_contents_t *zone,
FILE *f = fdopen(fd, "w");
if (f == NULL) {
log_zone_warning(zname, "failed to open zone master file");
WARNING(zname, "failed to open zone, file '%s' (%s)",
new_fname, knot_strerror(knot_errno_to_error(errno)));
unlink(new_fname);
free(new_fname);
return KNOT_ERROR;
}
if (zone_dump_text(zone, from, f) != KNOT_EOK) {
log_zone_warning(zname, "failed to save the transferred zone to '%s'",
new_fname);
WARNING(zname, "failed to save zone, file '%s'", new_fname);
fclose(f);
unlink(new_fname);
free(new_fname);
......@@ -396,8 +391,8 @@ int zonefile_write(const char *path, zone_contents_t *zone,
int ret = rename(new_fname, path);
if (ret < 0 && ret != EEXIST) {
log_zone_warning(zname, "failed to replace old zone file '%s' "
"with a new zone file '%s'", path, new_fname);
WARNING(zname, "failed to swap zone files, old '%s', new '%s'",
path, new_fname);
unlink(new_fname);
free(new_fname);
return KNOT_ERROR;
......@@ -419,3 +414,7 @@ void zonefile_close(zloader_t *loader)
free(loader->origin);
free(loader->creator);
}
#undef ERROR
#undef WARNING
#undef INFO
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment