feat(lander): fully switch to lnm logger
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docker Pipeline was successful Details

new-lnm-integration
Jef Roosens 2023-12-11 15:39:31 +01:00
parent dde83584a7
commit 8e0477c34b
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 5 additions and 34 deletions

View File

@ -1,12 +1,13 @@
#include <stdio.h>
#include <string.h>
#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[] =
"<!DOCTYPE html>\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);

View File

@ -1,8 +1,9 @@
#include <string.h>
#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);

View File

@ -1,31 +0,0 @@
#include <time.h>
#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");
}