diff options
-rw-r--r-- | lualib/lua_redis.lua | 10 | ||||
-rw-r--r-- | src/libserver/logger/logger.c | 26 |
2 files changed, 28 insertions, 8 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua index 48ea1b6ed..85f5ebc7a 100644 --- a/lualib/lua_redis.lua +++ b/lualib/lua_redis.lua @@ -1738,11 +1738,10 @@ exports.request = function(redis_params, attrs, req) opts.dbname = redis_params.db end - lutil.debugm(N, 'perform generic request to redis server' .. - ' (host=%s, timeout=%s): cmd: %s, arguments: %s', addr, - opts.timeout, opts.cmd, opts.args) - if opts.callback then + lutil.debugm(N, 'perform generic async request to redis server' .. + ' (host=%s, timeout=%s): cmd: %s, arguments: %s', addr, + opts.timeout, opts.cmd, opts.args) local ret, conn = rspamd_redis.make_request(opts) if not ret then logger.errx(log_obj, 'cannot execute redis request') @@ -1752,6 +1751,9 @@ exports.request = function(redis_params, attrs, req) return ret, conn, addr else -- Coroutines version + lutil.debugm(N, 'perform generic coroutine request to redis server' .. + ' (host=%s, timeout=%s): cmd: %s, arguments: %s', addr, + opts.timeout, opts.cmd, opts.args) local ret, conn = rspamd_redis.connect_sync(opts) if not ret then logger.errx(log_obj, 'cannot execute redis request') diff --git a/src/libserver/logger/logger.c b/src/libserver/logger/logger.c index 25818e7a5..dc0a85a05 100644 --- a/src/libserver/logger/logger.c +++ b/src/libserver/logger/logger.c @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1026,6 +1026,18 @@ log_time(double now, rspamd_logger_t *rspamd_log, char *timebuf, } } +static inline int +rspamd_log_id_strlen(const char *id) +{ + for (int i = 0; i < RSPAMD_LOG_ID_LEN; i++) { + if (G_UNLIKELY(id[i] == '\0')) { + return i; + } + } + + return RSPAMD_LOG_ID_LEN; +} + void rspamd_log_fill_iov(struct rspamd_logger_iov_ctx *iov_ctx, double ts, const char *module, @@ -1235,9 +1247,7 @@ void rspamd_log_fill_iov(struct rspamd_logger_iov_ctx *iov_ctx, m = modulebuf; if (id != NULL) { - unsigned int slen = strlen(id); - slen = MIN(RSPAMD_LOG_ID_LEN, slen); - mr = rspamd_snprintf(m, mremain, "<%*.s>; ", slen, + mr = rspamd_snprintf(m, mremain, "<%*.s>; ", rspamd_log_id_strlen(id), id); m += mr; mremain -= mr; @@ -1289,6 +1299,14 @@ void rspamd_log_fill_iov(struct rspamd_logger_iov_ctx *iov_ctx, if (logger->log_level == G_LOG_LEVEL_DEBUG) { iov_ctx->iov[niov].iov_base = (void *) timebuf; iov_ctx->iov[niov++].iov_len = strlen(timebuf); + if (id != NULL) { + iov_ctx->iov[niov].iov_base = (void *) "; "; + iov_ctx->iov[niov++].iov_len = 2; + iov_ctx->iov[niov].iov_base = (void *) id; + iov_ctx->iov[niov++].iov_len = rspamd_log_id_strlen(id); + iov_ctx->iov[niov].iov_base = (void *) ";"; + iov_ctx->iov[niov++].iov_len = 1; + } iov_ctx->iov[niov].iov_base = (void *) " "; iov_ctx->iov[niov++].iov_len = 1; } |