Commit e3c9a457 authored by Daniel Salzman's avatar Daniel Salzman

Unify logging messages

parent 5ffc7c66
......@@ -84,7 +84,7 @@ static void cf_print_error(void *scanner, const char *msg)
filename = new_config->filename;
}
log_error("Config error in '%s' (line %d token '%s'): %s\n",
log_error("config error in '%s' (line %d token '%s'): %s\n",
filename, lineno, text, msg);
_parser_res = KNOT_EPARSEFAIL;
......@@ -225,7 +225,7 @@ static int conf_process(conf_t *conf)
/* Check for ACL existence. */
if (!EMPTY_LIST(conf->ctl.allow)) {
log_warning("Control 'allow' statement does not "
log_warning("control 'allow' statement does not "
"affect UNIX sockets\n");
}
} else if (sockaddr_port(&ctl_if->addr) <= 0) {
......@@ -363,7 +363,7 @@ static int conf_process(conf_t *conf)
if (!EMPTY_LIST(zone->acl.notify_in) ||
!EMPTY_LIST(zone->acl.xfr_in)
) {
log_zone_str_warning(zone->name, "Automatic "
log_zone_str_notice(zone->name, "automatic "
"DNSSEC signing enabled, disabling "
"incoming XFRs\n");
......@@ -393,12 +393,14 @@ static int conf_process(conf_t *conf)
/* Check paths existence. */
if (!is_existing_dir(zone->storage)) {
log_error("Storage dir '%s' does not exist\n", zone->storage);
log_error("storage directory '%s' does not exist\n",
zone->storage);
ret = KNOT_EINVAL;
continue;
}
if (zone->dnssec_enable && !is_existing_dir(zone->dnssec_keydir)) {
log_error("DNSSEC key dir '%s' does not exist\n", zone->dnssec_keydir);
log_error("DNSSEC key directory '%s' does not exist\n",
zone->dnssec_keydir);
ret = KNOT_EINVAL;
continue;
......@@ -818,7 +820,7 @@ char* strcpath(char *path)
char* remainder = strchr(path,'~');
if (remainder != NULL) {
if (remainder[1] != '/') {
log_warning("Cannot expand non-login user home"
log_warning("cannot expand non-login user home"
"directory '%s', use full path instead", path);
}
......
......@@ -183,14 +183,14 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
/* Check remote address. */
conf_iface_t *r = conf()->ctl.iface;
if (!r || r->addr.ss_family == AF_UNSPEC) {
log_error("No remote address for '%s' configured.\n", cmd);
log_error("no remote address for '%s' configured\n", cmd);
return 1;
}
/* Make query. */
knot_pkt_t *pkt = remote_query(cmd, r->key);
if (!pkt) {
log_warning("Could not prepare query for '%s'.\n", cmd);
log_warning("could not prepare query for '%s'\n", cmd);
return 1;
}
......@@ -200,7 +200,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
knot_rrset_t rr;
int res = remote_build_rr(&rr, "data.", rrt);
if (res != KNOT_EOK) {
log_error("Couldn't create the query.\n");
log_error("couldn't create the query\n");
knot_pkt_free(&pkt);
return 1;
}
......@@ -217,7 +217,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
}
res = knot_pkt_put(pkt, 0, &rr, KNOT_PF_FREE);
if (res != KNOT_EOK) {
log_error("Couldn't create the query.\n");
log_error("couldn't create the query\n");
knot_rrset_clear(&rr, NULL);
knot_pkt_free(&pkt);
return 1;
......@@ -227,7 +227,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
if (r->key) {
int res = remote_query_sign(pkt->wire, &pkt->size, pkt->max_size, r->key);
if (res != KNOT_EOK) {
log_error("Couldn't sign the packet.\n");
log_error("couldn't sign the packet\n");
knot_pkt_free(&pkt);
return 1;
}
......@@ -241,7 +241,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
int s = net_connected_socket(SOCK_STREAM, &r->addr, &r->via, 0);
if (s < 0) {
log_error("Couldn't connect to remote host '%s'.\n", addr_str);
log_error("couldn't connect to remote host '%s'\n", addr_str);
knot_pkt_free(&pkt);
return 1;
}
......@@ -249,7 +249,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
/* Wait for availability. */
struct pollfd pfd = { s, POLLOUT, 0 };
if (poll(&pfd, 1, conf()->max_conn_reply) != 1) {
log_error("Couldn't connect to remote host '%s'.\n", addr_str);
log_error("couldn't connect to remote host '%s'\n", addr_str);
close(s);
knot_pkt_free(&pkt);
return 1;
......@@ -261,7 +261,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
/* Evaluate and wait for reply. */
if (ret <= 0) {
log_error("Couldn't connect to remote host '%s'.\n", addr_str);
log_error("couldn't connect to remote host '%s'\n", addr_str);
close(s);
return 1;
}
......@@ -272,7 +272,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
ret = cmd_remote_reply(s);
if (ret != KNOT_EOK) {
if (ret != KNOT_ECONN) {
log_warning("Remote command reply: %s\n",
log_warning("remote command reply: %s\n",
knot_strerror(ret));
rc = 1;
}
......@@ -373,7 +373,7 @@ static int tsig_parse_file(knot_tsig_key_t *k, const char *f)
{
FILE* fp = fopen(f, "r");
if (!fp) {
log_error("Couldn't open key-file '%s'.\n", f);
log_error("couldn't open key-file '%s'\n", f);
return KNOT_EINVAL;
}
......@@ -393,8 +393,8 @@ static int tsig_parse_file(knot_tsig_key_t *k, const char *f)
}
if (c == '\n') {
if (k->name) {
log_error("Only one key definition allowed "
"in '%s'.\n", f);
log_error("only one key definition allowed "
"in '%s'\n", f);
ret = KNOT_EMALF;
break;
}
......@@ -455,14 +455,14 @@ int main(int argc, char **argv)
case 'y':
if (tsig_parse_str(&r_key, optarg) != KNOT_EOK) {
rc = 1;
log_error("Couldn't parse TSIG key '%s'\n", optarg);
log_error("couldn't parse TSIG key '%s'\n", optarg);
goto exit;
}
break;
case 'k':
if (tsig_parse_file(&r_key, optarg) != KNOT_EOK) {
rc = 1;
log_error("Couldn't parse TSIG key file '%s'\n", optarg);
log_error("couldn't parse TSIG key file '%s'\n", optarg);
goto exit;
}
break;
......@@ -512,7 +512,7 @@ int main(int argc, char **argv)
/* Command not found. */
if (!cmd->name) {
log_error("Invalid command: '%s'\n", argv[optind]);
log_error("invalid command: '%s'\n", argv[optind]);
rc = 1;
goto exit;
}
......@@ -525,7 +525,7 @@ int main(int argc, char **argv)
/* Check if config file is required. */
if (has_flag(flags, F_NOCONF) && cmd->need_conf) {
log_error("Couldn't find a config file, refusing to continue\n");
log_error("couldn't find a config file, refusing to continue\n");
rc = 1;
goto exit;
}
......@@ -702,7 +702,7 @@ static int cmd_checkzone(int argc, char *argv[], unsigned flags)
continue;
}
log_zone_str_info(zone->name, "Zone is OK\n");
log_zone_str_info(zone->name, "zone is OK\n");
zone_contents_deep_free(&loaded_zone);
}
hattrie_iter_free(z_iter);
......@@ -759,7 +759,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
.htable_size = 0, .rdata_size = 0,
.record_count = 0 };
if (est.node_table == NULL) {
log_error("Not enough memory\n");
log_error("not enough memory\n");
continue;
}
......@@ -771,7 +771,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
&est);
if (loader == NULL) {
rc = 1;
log_zone_str_error(zone->name, "Could not load zone\n");
log_zone_str_error(zone->name, "could not load zone\n");
hattrie_free(est.node_table);
continue;
}
......@@ -780,7 +780,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
int ret = zs_loader_process(loader);
if (ret != KNOT_EOK) {
rc = 1;
log_zone_str_error(zone->name, "Failed to parse zone\n");
log_zone_str_error(zone->name, "failed to parse zone\n");
hattrie_apply_rev(est.node_table, estimator_free_trie_node, NULL);
hattrie_free(est.node_table);
zs_loader_free(loader);
......@@ -801,7 +801,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
est.htable_size +
malloc_size) * ESTIMATE_MAGIC) / (1024.0 * 1024.0);
log_zone_str_info(zone->name, "%zu RRs, used memory estimation is %zuMB\n",
log_zone_str_info(zone->name, "%zu RRs, used memory estimation is %zu MB\n",
est.record_count, (size_t)zone_size);
zs_loader_free(loader);
total_size += zone_size;
......@@ -810,7 +810,8 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
hattrie_iter_free(z_iter);
if (rc == 0 && argc == 0) { // for all zones
log_info("Estimated memory consumption for all zones is %zuMB\n", (size_t)total_size);
log_info("estimated memory consumption for all zones is %zu MB\n",
(size_t)total_size);
}
return rc;
......
......@@ -139,18 +139,18 @@ int proc_update_privileges(int uid, int gid)
/* Drop supplementary groups. */
if ((uid_t)uid != getuid() || (gid_t)gid != getgid()) {
if (setgroups(0, NULL) < 0) {
log_warning("Failed to drop supplementary groups for "
"uid '%d': %s\n", getuid(), strerror(errno));
log_warning("failed to drop supplementary groups for "
"UID '%d': %s\n", getuid(), strerror(errno));
}
# ifdef HAVE_INITGROUPS
struct passwd *pw;
if ((pw = getpwuid(uid)) == NULL) {
log_warning("Failed to get passwd entry for uid '%d': %s\n",
log_warning("failed to get passwd entry for UID '%d': %s\n",
uid, strerror(errno));
} else {
if (initgroups(pw->pw_name, gid) < 0) {
log_warning("Failed to set supplementary groups "
"for uid '%d': %s\n", uid, strerror(errno));
log_warning("failed to set supplementary groups "
"for UID '%d': %s\n", uid, strerror(errno));
}
}
# endif /* HAVE_INITGROUPS */
......@@ -159,15 +159,15 @@ int proc_update_privileges(int uid, int gid)
/* Watch uid/gid. */
if ((gid_t)gid != getgid()) {
log_info("Changing GID to '%d'\n", gid);
log_info("changing GID to '%d'\n", gid);
if (setregid(gid, gid) < 0) {
log_error("Failed to change GID to '%d'\n", gid);
log_error("failed to change GID to '%d'\n", gid);
}
}
if ((uid_t)uid != getuid()) {
log_info("Changing UID to '%d'.\n", uid);
log_info("changing UID to '%d'\n", uid);
if (setreuid(uid, uid) < 0) {
log_error("Failed to change UID to '%d'\n", uid);
log_error("failed to change UID to '%d'\n", uid);
}
}
......@@ -184,7 +184,7 @@ int proc_update_privileges(int uid, int gid)
assert(lfile != NULL);
FILE* fp = fopen(lfile, "w");
if (fp == NULL) {
log_warning("Storage directory '%s' is not writable\n",
log_warning("storage directory '%s' is not writable\n",
zone->storage);
ret = KNOT_EACCES;
} else {
......@@ -210,18 +210,18 @@ char *pid_check_and_create()
/* Check PID for existence and liveness. */
if (pid > 0 && pid_running(pid)) {
log_error("Server PID found, already running\n");
log_error("server PID found, already running\n");
free(pidfile);
return NULL;
} else if (stat(pidfile, &st) == 0) {
log_warning("Removing stale PID file '%s'\n", pidfile);
log_warning("removing stale PID file '%s'\n", pidfile);
pid_remove(pidfile);
}
/* Create a PID file. */
int ret = pid_write(pidfile);
if (ret != KNOT_EOK) {
log_error("Couldn't create a PID file '%s'\n", pidfile);
log_error("couldn't create a PID file '%s'\n", pidfile);
free(pidfile);
return NULL;
}
......
......@@ -411,7 +411,7 @@ int remote_bind(conf_iface_t *desc)
char addr_str[SOCKADDR_STRLEN] = {0};
sockaddr_tostr(&desc->addr, addr_str, sizeof(addr_str));
log_info("Binding remote control interface to '%s'\n", addr_str);
log_info("binding remote control interface to '%s'\n", addr_str);
/* Create new socket. */
mode_t old_umask = umask(KNOT_CTL_SOCKET_UMASK);
......@@ -424,7 +424,7 @@ int remote_bind(conf_iface_t *desc)
/* Start listening. */
int ret = listen(sock, TCP_BACKLOG_SIZE);
if (ret < 0) {
log_error("Could not bind to '%s'\n", addr_str);
log_error("could not bind to '%s'\n", addr_str);
close(sock);
return ret;
}
......@@ -563,7 +563,7 @@ static void log_command(const char *cmd, const remote_cmdargs_t* args)
}
}
log_info("Remote command: '%s%s'\n", cmd, params);
log_info("remote command: '%s %s'\n", 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("denied remote control for '%s', "
"no matching ACL\n", 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("denied remote control for '%s', "
"key required\n", 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("denied remote control for '%s', "
"key verification failed\n", addr_str);
remote_senderr(client, pkt->wire, pkt->size);
ret = KNOT_EACCES;
......
......@@ -44,7 +44,7 @@ static int init_dnssec_structs(const zone_contents_t *zone,
zone->apex->owner,
nsec3_enabled, zone_keys);
if (result != KNOT_EOK) {
log_zone_error(zone->apex->owner, "DNSSEC: Failed to load keys: %s\n",
log_zone_error(zone->apex->owner, "DNSSEC: failed to load keys: %s\n",
knot_strerror(result));
knot_free_zone_keys(zone_keys);
return result;
......@@ -72,10 +72,10 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
const knot_dname_t *zone_name = zone->apex->owner;
log_zone_info(zone_name, "DNSSEC: Signing started\n");
log_zone_info(zone_name, "DNSSEC: signing started\n");
uint32_t new_serial = zone_contents_next_serial(zone, zone_config->serial_policy);
dbg_dnssec_verb("Changeset empty before generating NSEC chain: %d\n",
dbg_dnssec_verb("changeset empty before generating NSEC chain: %d\n",
changeset_is_empty(out_ch));
// Init needed structs
......@@ -92,30 +92,30 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
result = knot_zone_create_nsec_chain(zone, out_ch,
&zone_keys, &policy);
if (result != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC: Could not create NSEC(3) chain: %s.\n",
log_zone_error(zone_name, "DNSSEC: could not create NSEC(3) chain: %s\n",
knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
}
dbg_dnssec_verb("Changeset empty after generating NSEC chain: %d\n",
dbg_dnssec_verb("changeset empty after generating NSEC chain: %d\n",
changeset_is_empty(out_ch));
// add missing signatures
result = knot_zone_sign(zone, &zone_keys, &policy, out_ch,
refresh_at);
if (result != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC: Error while signing: %s\n",
log_zone_error(zone_name, "DNSSEC: error while signing: %s\n",
knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
}
dbg_dnssec_verb("Changeset emtpy after signing: %d\n",
dbg_dnssec_verb("changeset emtpy after signing: %d\n",
changeset_is_empty(out_ch));
// Check if only SOA changed
if (changeset_is_empty(out_ch) &&
!knot_zone_sign_soa_expired(zone, &zone_keys, &policy)) {
log_zone_info(zone_name, "DNSSEC: No signing performed, zone is valid\n");
log_zone_info(zone_name, "DNSSEC: no signing performed, zone is valid\n");
knot_free_zone_keys(&zone_keys);
assert(changeset_is_empty(out_ch));
return KNOT_EOK;
......@@ -128,17 +128,17 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
result = knot_zone_sign_update_soa(&soa, &rrsigs, &zone_keys, &policy,
new_serial, out_ch);
if (result != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC: Not signing. Cannot update "
log_zone_error(zone_name, "DNSSEC: not signing, cannot update "
"SOA record: %s\n", knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
}
knot_free_zone_keys(&zone_keys);
dbg_dnssec_detail("Zone signed: changes=%zu\n",
dbg_dnssec_detail("zone signed: changes=%zu\n",
changeset_size(out_ch));
log_zone_info(zone_name, "DNSSEC: Successfully signed\n");
log_zone_info(zone_name, "DNSSEC: successfully signed\n");
return KNOT_EOK;
}
......@@ -195,7 +195,7 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
ret = knot_zone_sign_changeset(zone, in_ch, out_ch,
&zone_keys, &policy);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC: Failed to sign changeset: %s\n",
log_zone_error(zone_name, "DNSSEC: failed to sign changeset: %s\n",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
return ret;
......@@ -204,7 +204,7 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
// Create NSEC(3) chain
ret = knot_zone_create_nsec_chain(zone, out_ch, &zone_keys, &policy);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC: Failed to create NSEC(3) chain: %s\n",
log_zone_error(zone_name, "DNSSEC: failed to create NSEC(3) chain: %s\n",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
return ret;
......@@ -214,7 +214,7 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
ret = knot_zone_sign_nsecs_in_changeset(&zone_keys, &policy,
out_ch);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC: Failed to sign changeset: %s\n",
log_zone_error(zone_name, "DNSSEC: failed to sign changeset: %s\n",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
return ret;
......@@ -226,7 +226,7 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
ret = knot_zone_sign_update_soa(&soa, &rrsigs, &zone_keys, &policy,
new_serial, out_ch);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC: Failed to sign SOA RR: %s\n",
log_zone_error(zone_name, "DNSSEC: failed to sign SOA RR: %s\n",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
return ret;
......
......@@ -158,7 +158,7 @@ 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\n",
log_zone_warning(zone_name, "DNSSEC: failed to load key '%s': %s\n",
entry->d_name, knot_strerror(ret));
knot_free_key_params(&params);
continue;
......@@ -189,7 +189,7 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
if (!knot_dnssec_algorithm_is_zonesign(params.algorithm,
nsec3_enabled)
) {
log_zone_notice(zone_name, "DNSSEC: Ignoring key %d (%s): "
log_zone_notice(zone_name, "DNSSEC: ignoring key %d (%s): "
"incompatible algorithm\n",
params.keytag, entry->d_name);
knot_free_key_params(&params);
......@@ -198,7 +198,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 %d (%s): "
log_zone_notice(zone_name, "DNSSEC: ignoring key %d (%s): "
"duplicate keytag\n",
params.keytag, entry->d_name);
knot_free_key_params(&params);
......@@ -208,7 +208,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 "
log_zone_error(zone_name, "DNSSEC: failed to process "
"key %d (%s): %s\n",
params.keytag, entry->d_name,
knot_strerror(ret));
......@@ -217,7 +217,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\n",
log_zone_info(zone_name, "DNSSEC: loaded key %5d, file %s, %s, %s, %s\n",
params.keytag, entry->d_name,
key->is_ksk ? "KSK" : "ZSK",
key->is_active ? "active" : "inactive",
......
......@@ -62,7 +62,7 @@ static void knot_crypto_deinit(void)
static void pid_cleanup(char *pidfile)
{
if (pidfile && pid_remove(pidfile) < 0) {
log_warning("Failed to remove PID file\n");
log_warning("failed to remove PID file\n");
}
}
......@@ -114,12 +114,12 @@ static void setup_capabilities(void)
/* Apply. */
if (capng_apply(CAPNG_SELECT_BOTH) < 0) {
log_error("Couldn't set process capabilities: %s\n",
log_error("couldn't set process capabilities: %s\n",
strerror(errno));
}
} else {
log_info("User UID %d is not allowed to set capabilities, "
"skipping.\n", getuid());
log_info("user UID %d is not allowed to set capabilities, "
"skipping\n", getuid());
}
#endif /* HAVE_CAP_NG_H */
}
......@@ -267,7 +267,7 @@ int main(int argc, char **argv)
int res = conf_open(config_fn);
conf_t *config = conf();
if (res != KNOT_EOK) {
log_fatal("Couldn't load configuration '%s': %s\n",
log_fatal("couldn't load configuration '%s': %s\n",
config_fn, knot_strerror(res));
return EXIT_FAILURE;
}
......@@ -281,7 +281,7 @@ int main(int argc, char **argv)
server_t server;
res = server_init(&server, conf_bg_threads(config));
if (res != KNOT_EOK) {
log_fatal("Could not initialize server: %s\n", knot_strerror(res));
log_fatal("could not initialize server: %s\n", knot_strerror(res));
conf_free(conf());
log_close();
return EXIT_FAILURE;
......@@ -291,7 +291,7 @@ int main(int argc, char **argv)
* @note This MUST be done before we drop privileges. */
server_reconfigure(config, &server);
conf_add_hook(config, CONF_ALL, server_reconfigure, &server);
log_info("Configured %zu interfaces and %zu zones\n",
log_info("configured %zu interfaces and %zu zones\n",
list_size(&config->ifaces), hattrie_weight(config->zones));
......@@ -318,10 +318,10 @@ int main(int argc, char **argv)
log_info("PID stored in '%s'\n", pidfile);
if (chdir(daemon_root) != 0) {
log_warning("Can't change working directory to %s\n",
log_warning("can't change working directory to %s\n",
daemon_root);
} else {
log_info("Changed directory to %s.\n", daemon_root);
log_info("changed directory to %s\n", daemon_root);
}
}
......@@ -336,20 +336,20 @@ int main(int argc, char **argv)
rcu_register_thread();
/* Populate zone database and add reconfiguration hook. */
log_info("Loading zones\n");
log_info("loading zones\n");
server_update_zones(config, &server);
conf_add_hook(config, CONF_ALL, server_update_zones, &server);
/* Check number of loaded zones. */
if (knot_zonedb_size(server.zone_db) == 0) {
log_warning("No zones loaded\n");
log_warning("no zones loaded\n");
}
/* Start it up. */
log_info("Starting server\n");
log_info("starting server\n");
res = server_start(&server, config->async_start);
if (res != KNOT_EOK) {
log_fatal("Failed to start server: %s\n", knot_strerror(res));
log_fatal("failed to start server: %s\n", knot_strerror(res));
server_deinit(&server);
rcu_unregister_thread();
pid_cleanup(pidfile);
......@@ -359,9 +359,9 @@ int main(int argc, char **argv)
}
if (daemonize) {
log_info("Server started as a daemon, PID %ld\n", pid);
log_info("server started as a daemon, PID %ld\n", pid);
} else {
log_info("Server started in foreground, PID %ld\n", pid);
log_info("server started in foreground, PID %ld\n", pid);
init_signal_started();
}
......@@ -381,7 +381,7 @@ int main(int argc, char **argv)
/* Cleanup PID file. */
pid_cleanup(pidfile);
log_info("Shutting down\n");
log_info("shutting down\n");
log_close();
return EXIT_SUCCESS;
......
......@@ -23,7 +23,7 @@
/* Defines. */
#define ARPA_ZONE_LABELS 2
#define MODULE_ERR(msg...) log_error("Module 'synth_record': " msg)
#define MODULE_ERR(msg...) log_error("module 'synth_record': " msg)
/*! \brief Supported answer synthesis template types. */
enum synth_template_type {
......
......@@ -249,9 +249,10 @@ int axfr_query_process(knot_pkt_t *pkt, struct query_data *qdata)
return NS_PROC_FULL; /* Check for more. */
case KNOT_EOK: /* Last response. */
gettimeofday(&now, NULL);
AXFROUT_LOG(LOG_INFO, "finished, %.02fs, %u messages, " SIZE_FORMAT,
AXFROUT_LOG(LOG_INFO,
"finished, %.02f seconds, %u messages, %u bytes",
time_diff(&axfr->proc.tstamp, &now) / 1000.0,
axfr->proc.npkts, SIZE_PARAMS(axfr->proc.nbytes));
axfr->proc.npkts, axfr->proc.nbytes);
return NS_PROC_DONE;
break;
default: /* Generic error. */
......@@ -303,8 +304,8 @@ static int axfr_answer_init(struct answer_data *data)
}
/* AXFR-specific logging (internal, expects 'adata' variable set). */
#define AXFRIN_LOG(priority, msg...) \
ANSWER_LOG(priority, adata, "AXFR, incoming", msg)
#define AXFRIN_LOG(severity, msg...) \
ANSWER_LOG(severity, adata, "AXFR, incoming", msg)
static int axfr_answer_finalize(struct answer_data *adata)
{
......@@ -328,11 +329,11 @@ static int axfr_answer_finalize(struct answer_data *adata)
synchronize_rcu();
AXFRIN_LOG(LOG_INFO, "finished, "
"serial %u -> %u, %.02fs, %u messages, " SIZE_FORMAT,
"serial %u -> %u, %.02f seconds, %u messages, %u bytes",
zone_contents_serial(old_contents),
zone_contents_serial(proc->contents),
time_diff(&proc->tstamp, &now) / 1000.0,
proc->npkts, SIZE_PARAMS(proc->nbytes));
proc->npkts, proc->nbytes);
/* Do not free new contents with cleanup. */
zone_contents_deep_free(&old_contents);
......
......@@ -32,13 +32,6 @@
struct query_data;
struct answer_data;
/*! \brief This macro helps with data size formatting during xfr logging. */
#define SIZE_FORMAT "%s%.*f %s"
#define SIZE_PARAMS(value) (value) < 1024 ? "" : "~", \
(value) < 1024 ? 0 : 1, \
(value) < 1024 ? (float)(value) : (value) / 1024.0, \
(value) < 1024 ? "B" : "KiB"
/*! \brief Generic transfer processing state. */
struct xfr_proc {
list_t nodes; /* Items to process (ptrnode_t). */
......
......@@ -344,9 +344,10 @@ static int ixfrin_finalize(struct answer_data *adata)
struct timeval now = {0};
gettimeofday(&now, NULL);
IXFRIN_LOG(LOG_INFO, "finished, %.02fs, %u messages, " SIZE_FORMAT,
IXFRIN_LOG(LOG_INFO,
"finished, %.02f seconds, %u messages, %u bytes",
time_diff(&ixfr->proc.tstamp, &now) / 1000.0,
ixfr->proc.npkts, SIZE_PARAMS(ixfr->proc.nbytes));
ixfr->proc.npkts, ixfr->proc.nbytes);
return KNOT_EOK;
}
......@@ -613,9 +614,10 @@ int ixfr_query(knot_pkt_t *pkt, struct query_data *qdata)
return NS_PROC_FULL; /* Check for more. */
case KNOT_EOK: /* Last response. */
gettimeofday(&now, NULL);
IXFROUT_LOG(LOG_INFO, "finished, %.02fs, %u messages, " SIZE_FORMAT,
IXFROUT_LOG(LOG_INFO,
"finished, %.02f seconds, %u messages, %u bytes",
time_diff(&ixfr->proc.tstamp, &now) / 1000.0,
ixfr->proc.npkts, SIZE_PARAMS(ixfr->proc.nbytes));
ixfr->proc.npkts, ixfr->proc.nbytes);
ret = NS_PROC_DONE;
break;
default: /* Generic error. */
......
......@@ -44,7 +44,7 @@
/* NOTIFY-specific logging (internal, expects 'qdata' variable set). */
#define NOTIFY_QLOG(severity, msg...) \
QUERY_LOG(severity, qdata, "notify, incoming", msg)
QUERY_LOG(severity, qdata, "NOTIFY, incoming", msg)
static int notify_check_query(struct query_data *qdata)
{
......@@ -107,7 +107,7 @@ int notify_process_query(knot_pkt_t *pkt, struct query_data *qdata)
/* NOTIFY-specific logging (internal, expects 'adata' variable set). */
#define NOTIFY_RLOG(severity, msg...) \
ANSWER_LOG(severity, adata, "notify, incoming", msg)
ANSWER_LOG(severity, adata, "NOTIFY, outgoing", msg)
Please register or sign in to reply
int notify_process_answer(knot_pkt_t *pkt, struct answer_data *adata)
{
......@@ -120,7 +120,7 @@ int notify_process_answer(knot_pkt_t *pkt, struct answer_data *adata)
if (rcode != KNOT_RCODE_NOERROR) {