From 8e0477c34b01169b3cc25e55e0b149d9ed92b13f Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Mon, 11 Dec 2023 15:39:31 +0100 Subject: [PATCH] feat(lander): fully switch to lnm logger --- src/lander/lander_get.c | 5 +++-- src/lander/lander_post.c | 3 ++- src/log.c | 31 ------------------------------- 3 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 src/log.c diff --git a/src/lander/lander_get.c b/src/lander/lander_get.c index bb3ca08..24e93ba 100644 --- a/src/lander/lander_get.c +++ b/src/lander/lander_get.c @@ -1,12 +1,13 @@ #include +#include #include "lnm/http/consts.h" #include "lnm/http/loop.h" #include "lnm/loop.h" +#include "lnm/log.h" #include "lsm/store.h" #include "lander.h" -#include "log.h" static const char index_page[] = "\n" @@ -39,7 +40,7 @@ lnm_http_step_err lander_get_redirect(lnm_http_conn *conn) { // This shouldn't be able to happen if (lsm_entry_attr_get(&url_attr_val, c_ctx->entry, lander_attr_type_url) != lsm_error_ok) { - error("Entry of type redirect detected without URL attribute"); + lnm_lerror("lander", "%s", "Entry of type redirect detected without URL attribute"); ctx->res.status = lnm_http_status_internal_server_error; lsm_entry_close(c_ctx->entry); diff --git a/src/lander/lander_post.c b/src/lander/lander_post.c index 4bda832..1244cb7 100644 --- a/src/lander/lander_post.c +++ b/src/lander/lander_post.c @@ -1,8 +1,9 @@ +#include + #include "lnm/loop.h" #include "lsm/store.h" #include "lander.h" -#include "log.h" static void randomize_key(char *key, int len) { size_t charset_len = strlen(lander_key_charset); diff --git a/src/log.c b/src/log.c deleted file mode 100644 index 1ca0bc7..0000000 --- a/src/log.c +++ /dev/null @@ -1,31 +0,0 @@ -#include - -#include "log.h" - -const char *log_level_names[] = {"DEBUG", "INFO ", "WARN ", "ERROR", - "CRITICAL"}; - -log_level _log_level = log_level_debug; - -void _lander_log(log_level level, FILE *f, const char *fmt, ...) { - if (level < _log_level) { - return; - } - - // Log to stdout by default - f = (f == NULL) ? stdout : f; - - char date_str[32]; - - time_t now = time(NULL); - strftime(date_str, sizeof(date_str) - 1, "%Y-%m-%d %H:%M:%S", - localtime(&now)); - fprintf(f, "[%s][%s] ", date_str, log_level_names[level]); - - va_list ap; - va_start(ap, fmt); - vfprintf(f, fmt, ap); - va_end(ap); - - fprintf(f, "\n"); -}