Skip to content

Commit 3831d1d

Browse files
asl3gengliangwang
authored andcommitted
[SPARK-48623][CORE] Migrate FileAppender logs to structured logging
### What changes were proposed in this pull request? This PR migrates `src/main/scala/org/apache/spark/util/logging/FileAppender.scala` to comply with the scala style changes in #46947 ### Why are the changes needed? This makes development and PR review of the structured logging migration easier. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Tested by ensuring dev/scalastyle checks pass ### Was this patch authored or co-authored using generative AI tooling? No Closes #47394 from asl3/asl3/migratenewfiles. Authored-by: Amanda Liu <[email protected]> Signed-off-by: Gengliang Wang <[email protected]>
1 parent 41b37ae commit 3831d1d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

common/utils/src/main/scala/org/apache/spark/internal/LogKey.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ private[spark] object LogKeys {
758758
case object STORAGE_LEVEL_REPLICATION extends LogKey
759759
case object STORAGE_MEMORY_SIZE extends LogKey
760760
case object STORE_ID extends LogKey
761+
case object STRATEGY extends LogKey
761762
case object STREAMING_CONTEXT extends LogKey
762763
case object STREAMING_DATA_SOURCE_DESCRIPTION extends LogKey
763764
case object STREAMING_DATA_SOURCE_NAME extends LogKey

core/src/main/scala/org/apache/spark/util/logging/FileAppender.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package org.apache.spark.util.logging
2020
import java.io.{File, FileOutputStream, InputStream, IOException}
2121

2222
import org.apache.spark.SparkConf
23-
import org.apache.spark.internal.{config, Logging, MDC}
23+
import org.apache.spark.internal.{config, Logging, LogKeys, MDC}
2424
import org.apache.spark.internal.LogKeys._
2525
import org.apache.spark.util.{IntParam, Utils}
2626

@@ -177,8 +177,8 @@ private[spark] object FileAppender extends Logging {
177177
inputStream, file, new SizeBasedRollingPolicy(bytes), conf, closeStreams = closeStreams)
178178
case _ =>
179179
logWarning(
180-
log"Illegal size [${MDC(NUM_BYTES, rollingSizeBytes)}] " +
181-
log"for rolling executor logs, rolling logs not enabled")
180+
log"Illegal size [${MDC(LogKeys.NUM_BYTES, rollingSizeBytes)}] " +
181+
log"for rolling executor logs, rolling logs not enabled")
182182
new FileAppender(inputStream, file, closeStreams = closeStreams)
183183
}
184184
}
@@ -192,8 +192,8 @@ private[spark] object FileAppender extends Logging {
192192
createSizeBasedAppender()
193193
case _ =>
194194
logWarning(
195-
s"Illegal strategy [$rollingStrategy] for rolling executor logs, " +
196-
s"rolling logs not enabled")
195+
log"Illegal strategy [${MDC(LogKeys.STRATEGY, rollingStrategy)}] for " +
196+
log"rolling executor logs, rolling logs not enabled")
197197
new FileAppender(inputStream, file, closeStreams = closeStreams)
198198
}
199199
}

0 commit comments

Comments
 (0)