diff options
author | Lukáš Ježek <lukas.jezek@nic.cz> | 2021-05-24 11:13:53 +0200 |
---|---|---|
committer | Tomas Krizek <tomas.krizek@nic.cz> | 2021-07-29 11:40:49 +0200 |
commit | f16eb2c4eb4ffd72362cd5abf81c5f7f9c032d1b (patch) | |
tree | 22266cddf80f2cf1aa1a393b89837912dc322e43 /daemon/main.c | |
parent | log: lua interface (diff) | |
download | knot-resolver-f16eb2c4eb4ffd72362cd5abf81c5f7f9c032d1b.tar.xz knot-resolver-f16eb2c4eb4ffd72362cd5abf81c5f7f9c032d1b.zip |
log: split to groups
Diffstat (limited to 'daemon/main.c')
-rw-r--r-- | daemon/main.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/daemon/main.c b/daemon/main.c index f7e18896..cfff0d0c 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -56,7 +56,7 @@ static void signal_handler(uv_signal_t *handle, int signum) while (waitpid(-1, NULL, WNOHANG) > 0); break; default: - kr_log_error("unhandled signal: %d\n", signum); + kr_log_error(LOG_GRP_SYSTEM, "unhandled signal: %d\n", signum); break; } } @@ -153,8 +153,8 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, bool leader, struc case UV_NAMED_PIPE: /* echo 'quit()' | kresd ... */ break; default: - kr_log_error( - "[system] error: standard input is not a terminal or pipe; " + kr_log_error(LOG_GRP_SYSTEM, "[system] " + "error: standard input is not a terminal or pipe; " "use '-n' if you want non-interactive mode. " "Commands can be simply added to your configuration file or sent over the control socket.\n" ); @@ -249,12 +249,12 @@ static int parse_args(int argc, char **argv, struct args *args) kr_require(optarg); args->forks = strtol(optarg, NULL, 10); if (args->forks == 1) { - kr_log_deprecate("use --noninteractive instead of --forks=1\n"); + kr_log_deprecate(LOG_GRP_SYSTEM, "use --noninteractive instead of --forks=1\n"); } else { - kr_log_deprecate("support for running multiple --forks will be removed\n"); + kr_log_deprecate(LOG_GRP_SYSTEM, "support for running multiple --forks will be removed\n"); } if (args->forks <= 0) { - kr_log_error("[system] error '-f' requires a positive" + kr_log_error(LOG_GRP_SYSTEM, "error '-f' requires a positive" " number, not '%s'\n", optarg); return EXIT_FAILURE; } @@ -294,7 +294,7 @@ static int parse_args(int argc, char **argv, struct args *args) /* Some other kind; no checks here. */ ffd.flags.kind = strdup(endptr + 1); } else { - kr_log_error("[system] incorrect value passed to '-S/--fd': %s\n", + kr_log_error(LOG_GRP_SYSTEM, "incorrect value passed to '-S/--fd': %s\n", optarg); return EXIT_FAILURE; } @@ -353,7 +353,7 @@ static int bind_sockets(addr_array_t *addrs, bool tls, flagged_fd_array_t *fds) } free(sa); if (ret != 0) { - kr_log_error("[system] bind to '%s'%s: %s\n", + kr_log_error(LOG_GRP_NETWORK, "[network] bind to '%s'%s: %s\n", addrs->at[i], tls ? " (TLS)" : "", kr_strerror(ret)); has_error = true; } @@ -372,7 +372,7 @@ static int start_listening(struct network *net, flagged_fd_array_t *fds) { /* TODO: try logging address@port. It's not too important, * because typical problems happen during binding already. * (invalid address, permission denied) */ - kr_log_error("[system] listen on fd=%d: %s\n", + kr_log_error(LOG_GRP_NETWORK, "[network] listen on fd=%d: %s\n", ffd->fd, kr_strerror(ret)); /* Continue printing all of these before exiting. */ } else { @@ -396,7 +396,7 @@ static void drop_capabilities(void) /* Apply. */ if (capng_apply(CAPNG_SELECT_BOTH) < 0) { - kr_log_error("[system] failed to set process capabilities: %s\n", + kr_log_error(LOG_GRP_SYSTEM, "[system] failed to set process capabilities: %s\n", strerror(errno)); } else { kr_log_verbose("[system] all capabilities dropped\n"); @@ -411,12 +411,12 @@ static void drop_capabilities(void) int main(int argc, char **argv) { if (setvbuf(stdout, NULL, _IONBF, 0) || setvbuf(stderr, NULL, _IONBF, 0)) { - kr_log_error("[system] failed to to set output buffering (ignored): %s\n", + kr_log_error(LOG_GRP_SYSTEM, "[system] failed to to set output buffering (ignored): %s\n", strerror(errno)); fflush(stderr); } if (strcmp("linux", OPERATING_SYSTEM) != 0) - kr_log_info("[warn] Knot Resolver is tested on Linux, other platforms might exhibit bugs.\n" + kr_log_warning(LOG_GRP_SYSTEM, "Knot Resolver is tested on Linux, other platforms might exhibit bugs.\n" "Please report issues to https://gitlab.nic.cz/knot/knot-resolver/issues/\n" "Thank you for your time and interest!\n"); @@ -436,7 +436,7 @@ int main(int argc, char **argv) /* FIXME: access isn't a good way if we start as root and drop privileges later */ if (access(the_args->rundir, W_OK) != 0 || chdir(the_args->rundir) != 0) { - kr_log_error("[system] rundir '%s': %s\n", + kr_log_error(LOG_GRP_SYSTEM, "[system] rundir '%s': %s\n", the_args->rundir, strerror(errno)); return EXIT_FAILURE; } @@ -454,7 +454,7 @@ int main(int argc, char **argv) } else if (access(config, R_OK) != 0) { char cwd[PATH_MAX]; get_workdir(cwd, sizeof(cwd)); - kr_log_error("[system] config '%s' (workdir '%s'): %s\n", + kr_log_error(LOG_GRP_SYSTEM, "[system] config '%s' (workdir '%s'): %s\n", config, cwd, strerror(errno)); return EXIT_FAILURE; } @@ -475,10 +475,10 @@ int main(int argc, char **argv) ret = setrlimit(RLIMIT_NOFILE, &rlim); } if (ret) { - kr_log_error("[system] failed to get or set file-descriptor limit: %s\n", + kr_log_error(LOG_GRP_SYSTEM, "[system] failed to get or set file-descriptor limit: %s\n", strerror(errno)); } else if (rlim.rlim_cur < 512*1024) { - kr_log_info("[system] warning: hard limit for number of file-descriptors is only %ld but recommended value is 524288\n", + kr_log_warning(LOG_GRP_SYSTEM, "[system] warning: hard limit for number of file-descriptors is only %ld but recommended value is 524288\n", (long)rlim.rlim_cur); } @@ -496,13 +496,13 @@ int main(int argc, char **argv) static struct engine engine; ret = engine_init(&engine, &pool); if (ret != 0) { - kr_log_error("[system] failed to initialize engine: %s\n", kr_strerror(ret)); + kr_log_error(LOG_GRP_SYSTEM, "[system] failed to initialize engine: %s\n", kr_strerror(ret)); return EXIT_FAILURE; } /* Initialize the worker */ ret = worker_init(&engine, the_args->forks); if (ret != 0) { - kr_log_error("[system] failed to initialize worker: %s\n", kr_strerror(ret)); + kr_log_error(LOG_GRP_SYSTEM, "[system] failed to initialize worker: %s\n", kr_strerror(ret)); return EXIT_FAILURE; } @@ -529,7 +529,7 @@ int main(int argc, char **argv) } } if (ret) { - kr_log_error("[system] failed to set up signal handlers: %s\n", + kr_log_error(LOG_GRP_SYSTEM, "[system] failed to set up signal handlers: %s\n", strerror(abs(errno))); ret = EXIT_FAILURE; goto cleanup; @@ -538,7 +538,7 @@ int main(int argc, char **argv) * (of the usual type) may skew results, e.g. epoll_pwait() taking lots of time. */ ret = uv_loop_configure(loop, UV_LOOP_BLOCK_SIGNAL, SIGPROF); if (ret) { - kr_log_info("[system] failed to block SIGPROF in event loop, ignoring: %s\n", + kr_log_info(LOG_GRP_SYSTEM, "[system] failed to block SIGPROF in event loop, ignoring: %s\n", uv_strerror(ret)); } @@ -550,7 +550,7 @@ int main(int argc, char **argv) ret = udp_queue_init_global(loop); if (ret) { - kr_log_error("[system] failed to initialize UDP queue: %s\n", + kr_log_error(LOG_GRP_SYSTEM, "[system] failed to initialize UDP queue: %s\n", kr_strerror(ret)); ret = EXIT_FAILURE; goto cleanup; |