From 96d14fe2638705436db9c61bb0100c550c42e774 Mon Sep 17 00:00:00 2001 From: Bany <53461381+0del@users.noreply.github.com> Date: Wed, 17 Apr 2024 19:38:21 +0700 Subject: [PATCH] Change Redis to Valkey in log messages (#226) Log messages containing "Redis" in some files are changed. Add macro SERVER_TITLE defined to "Valkey" (uppercase V) is introduced and used in log messages, so at least it will be easy to patch this definition to get Redis or any other name in the logs instead of Valkey. Change "Redis" in some log messages to use %s and SERVER_TITLE. This is a partial implementation of https://github.com/valkey-io/valkey/issues/207 --------- Signed-off-by: 0del --- src/acl.c | 6 +++--- src/cluster_legacy.c | 10 +++++----- src/eval.c | 6 +++--- src/version.h | 5 +++++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/acl.c b/src/acl.c index 787ef170e4..c6c2b15b19 100644 --- a/src/acl.c +++ b/src/acl.c @@ -2572,11 +2572,11 @@ int ACLSaveToFile(const char *filename) { void ACLLoadUsersAtStartup(void) { if (server.acl_filename[0] != '\0' && listLength(UsersToLoad) != 0) { serverLog(LL_WARNING, - "Configuring Redis with users defined in redis.conf and at " + "Configuring %s with users defined in valkey.conf and at " "the same setting an ACL file path is invalid. This setup " "is very likely to lead to configuration errors and security " "holes, please define either an ACL file or declare users " - "directly in your redis.conf, but not both."); + "directly in your valkey.conf, but not both.", SERVER_TITLE); exit(1); } @@ -2590,7 +2590,7 @@ void ACLLoadUsersAtStartup(void) { sds errors = ACLLoadFromFile(server.acl_filename); if (errors) { serverLog(LL_WARNING, - "Aborting Redis startup because of ACL errors: %s", errors); + "Aborting %s startup because of ACL errors: %s", SERVER_TITLE, errors); sdsfree(errors); exit(1); } diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 843e6299c9..bb7490a00b 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -791,7 +791,7 @@ int clusterLockConfig(char *filename) { if (errno == EWOULDBLOCK) { serverLog(LL_WARNING, "Sorry, the cluster configuration file %s is already used " - "by a different Redis Cluster node. Please make sure that " + "by a different Cluster node. Please make sure that " "different nodes use different cluster configuration " "files.", filename); } else { @@ -1011,10 +1011,10 @@ void clusterInit(void) { * us from trying to use a too-high cluster port number. */ int port = defaultClientPort(); if (!server.cluster_port && port > (65535-CLUSTER_PORT_INCR)) { - serverLog(LL_WARNING, "Redis port number too high. " + serverLog(LL_WARNING, "%s port number too high. " "Cluster communication port is 10,000 port " - "numbers higher than your Redis port. " - "Your Redis port number must be 55535 or less."); + "numbers higher than your %s port. " + "Your %s port number must be 55535 or less.", SERVER_TITLE, SERVER_TITLE, SERVER_TITLE); exit(1); } if (!server.bindaddr_count) { @@ -1055,7 +1055,7 @@ void clusterInitLast(void) { } if (createSocketAcceptHandler(&server.clistener, clusterAcceptHandler) != C_OK) { - serverPanic("Unrecoverable error creating Redis Cluster socket accept handler."); + serverPanic("Unrecoverable error creating Cluster socket accept handler."); } } diff --git a/src/eval.c b/src/eval.c index 0a97bb2536..061439014b 100644 --- a/src/eval.c +++ b/src/eval.c @@ -888,7 +888,7 @@ int ldbStartSession(client *c) { /* Log the creation of the child and close the listening * socket to make sure if the parent crashes a reset is sent * to the clients. */ - serverLog(LL_NOTICE,"Redis forked for debugging eval"); + serverLog(LL_NOTICE,"%s forked for debugging eval", SERVER_TITLE); } else { /* Parent */ listAddNodeTail(ldb.children,(void*)(unsigned long)cp); @@ -897,7 +897,7 @@ int ldbStartSession(client *c) { } } else { serverLog(LL_NOTICE, - "Redis synchronous debugging eval session started"); + "%s synchronous debugging eval session started", SERVER_TITLE); } /* Setup our debugging session. */ @@ -934,7 +934,7 @@ void ldbEndSession(client *c) { exitFromChild(0); } else { serverLog(LL_NOTICE, - "Redis synchronous debugging eval session ended"); + "%s synchronous debugging eval session ended", SERVER_TITLE); } /* Otherwise let's restore client's state. */ diff --git a/src/version.h b/src/version.h index 3b2e3a0601..d294050d3d 100644 --- a/src/version.h +++ b/src/version.h @@ -1,4 +1,9 @@ +/* These macros are used where the server name is printed in logs and replies. + * Note the difference in the first letter "V" vs "v". SERVER_TITLE is used in + * readable text like log messages and SERVER_NAME is used in INFO fields and + * similar. */ #define SERVER_NAME "valkey" +#define SERVER_TITLE "Valkey" #define VALKEY_VERSION "255.255.255" #define VALKEY_VERSION_NUM 0x00ffffff