Skip to content

Commit 88cec18

Browse files
feat: add printWarningLogOnce to suppress per-record deprecation spam
Replace per-record printWarningLog calls for DEPRECATED_SKYFLOW_ID_KEY with printWarningLogOnce so the deprecation notice fires at most once per JVM session regardless of result set size. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2740de4 commit 88cec18

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/main/java/com/skyflow/utils/logger/LogUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
import com.skyflow.logs.InfoLogs;
55
import com.skyflow.utils.Constants;
66

7+
import java.util.Collections;
8+
import java.util.Set;
9+
import java.util.concurrent.ConcurrentHashMap;
710
import java.util.logging.*;
811

912
public final class LogUtil {
1013
private static final Logger LOGGER = Logger.getLogger(LogUtil.class.getName());
1114
private static final String SDK_LOG_PREFIX = "[" + Constants.SDK_PREFIX + "] ";
1215
private static boolean isLoggerSetupDone = false;
16+
private static final Set<String> WARNED_ONCE = Collections.newSetFromMap(new ConcurrentHashMap<>());
1317

1418
synchronized public static void setupLogger(LogLevel logLevel) {
1519
isLoggerSetupDone = true;
@@ -56,6 +60,11 @@ public static void printWarningLog(String message) {
5660
LOGGER.warning(SDK_LOG_PREFIX + message);
5761
}
5862

63+
public static void printWarningLogOnce(String message) {
64+
if (isLoggerSetupDone && WARNED_ONCE.add(message))
65+
LOGGER.warning(SDK_LOG_PREFIX + message);
66+
}
67+
5968
public static void printInfoLog(String message) {
6069
if (isLoggerSetupDone)
6170
LOGGER.info(SDK_LOG_PREFIX + message);

src/main/java/com/skyflow/vault/controller/VaultController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private static synchronized HashMap<String, Object> getFormattedGetRecord(V1Fiel
133133

134134
if (getRecord.containsKey("skyflow_id")) {
135135
getRecord.put("skyflowId", getRecord.get("skyflow_id"));
136-
LogUtil.printWarningLog(InfoLogs.DEPRECATED_SKYFLOW_ID_KEY.getLog());
136+
LogUtil.printWarningLogOnce(InfoLogs.DEPRECATED_SKYFLOW_ID_KEY.getLog());
137137
}
138138

139139
return getRecord;
@@ -158,7 +158,7 @@ private static synchronized HashMap<String, Object> getFormattedQueryRecord(V1Fi
158158

159159
if (queryRecord.containsKey("skyflow_id")) {
160160
queryRecord.put("skyflowId", queryRecord.get("skyflow_id"));
161-
LogUtil.printWarningLog(InfoLogs.DEPRECATED_SKYFLOW_ID_KEY.getLog());
161+
LogUtil.printWarningLogOnce(InfoLogs.DEPRECATED_SKYFLOW_ID_KEY.getLog());
162162
}
163163

164164
return queryRecord;

0 commit comments

Comments
 (0)