Skip to content

Commit

Permalink
[SPARK-48623][CORE] Migrate FileAppender logs to structured logging
Browse files Browse the repository at this point in the history
### 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 apache#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 apache#47394 from asl3/asl3/migratenewfiles.

Authored-by: Amanda Liu <amanda.liu@databricks.com>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
  • Loading branch information
asl3 authored and attilapiros committed Oct 4, 2024
1 parent 21f5ae3 commit 7c9f252
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ private[spark] object LogKeys {
case object STORAGE_LEVEL_REPLICATION extends LogKey
case object STORAGE_MEMORY_SIZE extends LogKey
case object STORE_ID extends LogKey
case object STRATEGY extends LogKey
case object STREAMING_CONTEXT extends LogKey
case object STREAMING_DATA_SOURCE_DESCRIPTION extends LogKey
case object STREAMING_DATA_SOURCE_NAME extends LogKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package org.apache.spark.util.logging
import java.io.{File, FileOutputStream, InputStream, IOException}

import org.apache.spark.SparkConf
import org.apache.spark.internal.{config, Logging, MDC}
import org.apache.spark.internal.{config, Logging, LogKeys, MDC}
import org.apache.spark.internal.LogKeys._
import org.apache.spark.util.{IntParam, Utils}

Expand Down Expand Up @@ -177,8 +177,8 @@ private[spark] object FileAppender extends Logging {
inputStream, file, new SizeBasedRollingPolicy(bytes), conf, closeStreams = closeStreams)
case _ =>
logWarning(
log"Illegal size [${MDC(NUM_BYTES, rollingSizeBytes)}] " +
log"for rolling executor logs, rolling logs not enabled")
log"Illegal size [${MDC(LogKeys.NUM_BYTES, rollingSizeBytes)}] " +
log"for rolling executor logs, rolling logs not enabled")
new FileAppender(inputStream, file, closeStreams = closeStreams)
}
}
Expand All @@ -192,8 +192,8 @@ private[spark] object FileAppender extends Logging {
createSizeBasedAppender()
case _ =>
logWarning(
s"Illegal strategy [$rollingStrategy] for rolling executor logs, " +
s"rolling logs not enabled")
log"Illegal strategy [${MDC(LogKeys.STRATEGY, rollingStrategy)}] for " +
log"rolling executor logs, rolling logs not enabled")
new FileAppender(inputStream, file, closeStreams = closeStreams)
}
}
Expand Down

0 comments on commit 7c9f252

Please sign in to comment.