From 466115bc395f1ff0d91a0fba44e2bf390f58597b Mon Sep 17 00:00:00 2001 From: blank X Date: Mon, 17 Jan 2022 16:49:54 +0700 Subject: [PATCH] Use correct log levels --- src/config.cpp | 14 +++++++------- src/imgurxp.cpp | 18 +++++++++--------- src/proxy_image.cpp | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 196e8fd..2a1b97b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -19,13 +19,13 @@ void kore_parent_configure(int argc, char* argv[]) { } config_fstream.close(); if (config_fstream.fail() && !config_fstream.eof()) { - kore_log(LOG_NOTICE, "fail bit set when reading config"); + kore_log(LOG_ERR, "fail bit set when reading config"); exit(1); } kore_json json; kore_json_init(&json, config_str.c_str(), config_str.length()); if (kore_json_parse(&json) != KORE_RESULT_OK) { - kore_log(LOG_NOTICE, "failed to parse json: %s", kore_json_strerror(&json)); + kore_log(LOG_ERR, "failed to parse json: %s", kore_json_strerror(&json)); exit(1); } kore_json_item* redis_host_json = kore_json_find_string(json.root, "redis_host"); @@ -42,16 +42,16 @@ void kore_parent_configure(int argc, char* argv[]) { void kore_worker_configure() { if (config.redis_host && config.redis_port) { - kore_log(LOG_NOTICE, "connecting to redis instance at %s:%d", (*config.redis_host).c_str(), (*config.redis_port)); + kore_log(LOG_INFO, "connecting to redis instance at %s:%d", (*config.redis_host).c_str(), (*config.redis_port)); struct timeval timeout = {1, 0}; redis = redisConnectWithTimeout((*config.redis_host).c_str(), (*config.redis_port), timeout); if (!redis || redis->err) { if (redis) { - kore_log(LOG_NOTICE, "failed to connect to redis: %s", redis->errstr); + kore_log(LOG_ERR, "failed to connect to redis: %s", redis->errstr); redisFree(redis); redis = nullptr; } else { - kore_log(LOG_NOTICE, "failed to connect to redis"); + kore_log(LOG_ERR, "failed to connect to redis"); } kore_shutdown(); exit(1); @@ -60,9 +60,9 @@ void kore_worker_configure() { redisReply* reply = (redisReply*)redisCommand(redis, "AUTH %s", (*config.redis_password).c_str()); if (!reply || reply->type == REDIS_REPLY_ERROR) { if (!reply) { - kore_log(LOG_NOTICE, "received nullptr while authenticating to redis"); + kore_log(LOG_ERR, "received nullptr while authenticating to redis"); } else { - kore_log(LOG_NOTICE, "received error while authenticating to redis: %s", reply->str); + kore_log(LOG_ERR, "received error while authenticating to redis: %s", reply->str); freeReplyObject(reply); } redisFree(redis); diff --git a/src/imgurxp.cpp b/src/imgurxp.cpp index f109def..7957973 100644 --- a/src/imgurxp.cpp +++ b/src/imgurxp.cpp @@ -28,11 +28,11 @@ static bool send_hget_and_http_resp(struct http_request* req, const char* id, bo redisReply* reply = (redisReply*)redisCommand(redis, "HGET %s %s", keys.key.c_str(), keys.field.c_str()); if (!reply) { redis_mutex.unlock(); - kore_log(LOG_NOTICE, "received nullptr while sending HGET to redis"); + kore_log(LOG_WARNING, "received nullptr while sending HGET to redis"); return false; } if (reply->type == REDIS_REPLY_ERROR) { - kore_log(LOG_NOTICE, "received error while sending HGET to redis: %s", reply->str); + kore_log(LOG_WARNING, "received error while sending HGET to redis: %s", reply->str); freeReplyObject(reply); redis_mutex.unlock(); return false; @@ -58,7 +58,7 @@ static bool send_hget_and_http_resp(struct http_request* req, const char* id, bo freeReplyObject(reply); redis_mutex.unlock(); if (error) { - kore_log(LOG_NOTICE, "received error while parsing packed album: %s", (*error).c_str()); + kore_log(LOG_WARNING, "received error while parsing packed album: %s", (*error).c_str()); return false; } send_album_page(req, std::move(album)); @@ -89,7 +89,7 @@ static int album_or_image_start(struct http_request* req) { struct kore_curl* client = (kore_curl*)http_state_create(req, sizeof(*client), NULL); if (!kore_curl_init(client, api_url.c_str(), KORE_CURL_ASYNC)) { http_state_cleanup(req); - kore_log(LOG_NOTICE, "failed to initialize curl client"); + kore_log(LOG_ERR, "failed to initialize curl client"); std::string error_page = build_error_page("Failed to initialize curl client"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; @@ -109,11 +109,11 @@ static void send_hset(const char* id, bool is_album, const char* packed) { redisReply* reply = (redisReply*)redisCommand(redis, "HSET %s %s %s", keys.key.c_str(), keys.field.c_str(), packed); if (!reply) { redis_mutex.unlock(); - kore_log(LOG_NOTICE, "received nullptr while sending HSET to redis"); + kore_log(LOG_WARNING, "received nullptr while sending HSET to redis"); return; } if (reply->type == REDIS_REPLY_ERROR) { - kore_log(LOG_NOTICE, "received error while sending HSET to redis: %s", reply->str); + kore_log(LOG_WARNING, "received error while sending HSET to redis: %s", reply->str); freeReplyObject(reply); redis_mutex.unlock(); return; @@ -146,7 +146,7 @@ static int album_or_image_end(struct http_request* req) { kore_json json; kore_json_init(&json, body, strlen(body)); if (kore_json_parse(&json) != KORE_RESULT_OK) { - kore_log(LOG_NOTICE, "failed to parse json: %s", kore_json_strerror(&json)); + kore_log(LOG_ERR, "failed to parse json: %s", kore_json_strerror(&json)); std::string error = "Failed to parse response: "; error.append(kore_json_strerror(&json)); kore_json_cleanup(&json); @@ -191,7 +191,7 @@ static int album_or_image_end(struct http_request* req) { if (error_detail_json) { error_detail = error_detail_json->data.string; } - kore_log(LOG_NOTICE, "received error from api: %s: %s", error_code, error_detail); + kore_log(LOG_ERR, "received error from api: %s: %s", error_code, error_detail); std::string to_append; if (needs_newline) { to_append.append("\n"); @@ -217,7 +217,7 @@ static int album_or_image_end(struct http_request* req) { kore_curl_cleanup(client); http_state_cleanup(req); if (error) { - kore_log(LOG_NOTICE, "%s", (*error).c_str()); + kore_log(LOG_ERR, "%s", (*error).c_str()); std::string error_page = build_error_page((*error).c_str()); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; diff --git a/src/proxy_image.cpp b/src/proxy_image.cpp index 5d62aa5..e7ae637 100644 --- a/src/proxy_image.cpp +++ b/src/proxy_image.cpp @@ -28,7 +28,7 @@ static int proxy_start(struct http_request* req) { struct kore_curl* client = (kore_curl*)http_state_create(req, sizeof(*client), NULL); if (!kore_curl_init(client, url.c_str(), KORE_CURL_ASYNC)) { http_state_cleanup(req); - kore_log(LOG_NOTICE, "failed to initialize curl client"); + kore_log(LOG_ERR, "failed to initialize curl client"); std::string error_page = build_error_page("Failed to initialize curl client"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE;