summaryrefslogtreecommitdiff
path: root/logger.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2020-06-10 22:56:07 -0700
committerdormando <dormando@rydia.net>2021-10-05 12:21:25 -0700
commitd22b66483bce8843110795609386edc6ebf65b69 (patch)
treeac2107f9450c857d9ed125a17aef79a4158da7f9 /logger.c
parent56dc81db316a0b957415e371d20c683fea9d7d2f (diff)
downloadmemcached-d22b66483bce8843110795609386edc6ebf65b69.tar.gz
proxy: initial commit.
See BUILD for compilation details. See t/startfile.lua for configuration examples. (see also https://github.com/memcached/memcached-proxylibs for extensions, config libraries, more examples) NOTE: io_uring mode is _not stable_, will crash. As of this commit it is not recommended to run the proxy in production. If you are interested please let us know, as we are actively stabilizing for production use.
Diffstat (limited to 'logger.c')
-rw-r--r--logger.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/logger.c b/logger.c
index 667f3c7..0a6cdff 100644
--- a/logger.c
+++ b/logger.c
@@ -303,6 +303,34 @@ static int _logger_parse_cce(logentry *e, char *scratch) {
return total;
}
+#ifdef PROXY
+static void _logger_log_proxy_raw(logentry *e, const entry_details *d, const void *entry, va_list ap) {
+ struct timeval start = va_arg(ap, struct timeval);
+ char *cmd = va_arg(ap, char *);
+ unsigned short type = va_arg(ap, int);
+ unsigned short code = va_arg(ap, int);
+
+ struct logentry_proxy_raw *le = (void *)e->data;
+ struct timeval end;
+ gettimeofday(&end, NULL);
+ le->type = type;
+ le->code = code;
+ le->elapsed = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
+ memcpy(le->cmd, cmd, 9);
+}
+
+static int _logger_parse_prx_raw(logentry *e, char *scratch) {
+ int total;
+ struct logentry_proxy_raw *le = (void *)e->data;
+
+ total = snprintf(scratch, LOGGER_PARSE_SCRATCH,
+ "ts=%d.%d gid=%llu type=proxy_raw elapsed=%lu cmd=%s type=%d code=%d\n",
+ (int) e->tv.tv_sec, (int) e->tv.tv_usec, (unsigned long long) e->gid,
+ le->elapsed, le->cmd, le->type, le->code);
+ return total;
+}
+#endif
+
/* Should this go somewhere else? */
static const entry_details default_entries[] = {
[LOGGER_ASCII_CMD] = {512, LOG_RAWCMDS, _logger_log_text, _logger_parse_text, "<%d %s"},
@@ -338,6 +366,15 @@ static const entry_details default_entries[] = {
"type=compact_fraginfo ratio=%.2f bytes=%lu"
},
#endif
+#ifdef PROXY
+ [LOGGER_PROXY_CONFIG] = {512, LOG_SYSEVENTS, _logger_log_text, _logger_parse_text,
+ "type=proxy_conf status=%s"
+ },
+ [LOGGER_PROXY_RAW] = {512, LOG_RAWCMDS, _logger_log_proxy_raw, _logger_parse_prx_raw, NULL},
+ [LOGGER_PROXY_ERROR] = {512, LOG_SYSEVENTS, _logger_log_text, _logger_parse_text,
+ "type=proxy_error msg=%s"
+ },
+#endif
};
/*************************