From b3130056f5a38d571225a279a732d4edb31c13c7 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Tue, 18 Jul 2023 14:23:19 +0100 Subject: [PATCH] HADOOP-18808. LogExactlyOnce to add a debug() method (#5850) Contributed by Steve Loughran --- .../org/apache/hadoop/fs/store/LogExactlyOnce.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/LogExactlyOnce.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/LogExactlyOnce.java index 04cd5111e9..e32c0e424a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/LogExactlyOnce.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/LogExactlyOnce.java @@ -49,4 +49,15 @@ public void error(String format, Object...args) { log.error(format, args); } } + + /** + * Log at DEBUG if nothing has been logged yet. + * @param format format string + * @param args arguments + */ + public void debug(String format, Object...args) { + if (!logged.getAndSet(true)) { + log.debug(format, args); + } + } }