[ 
https://issues.apache.org/jira/browse/SPARK-48744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gengliang Wang updated SPARK-48744:
-----------------------------------
    Description: 
In the current implementation:

```

class LogEntry(messageWithContext: => MessageWithContext) {

  def message: String = mwc.message

  def context: java.util.HashMap[String, String] = mwc.context
}

def logInfo(entry: LogEntry): Unit = {
  if (log.isInfoEnabled) {
    withLogContext(entry.context) {
      log.info(entry.message)
    }
  }
}

```

The field `messageWithContext` is constructed twice, one from `entry.context` 
and another one from `entry.message`.

We should improve this.

  was:
In the current implementation:

```

class LogEntry(messageWithContext: => MessageWithContext) {
  def message: String = messageWithContext.message

  def context: java.util.HashMap[String, String] = messageWithContext.context
}

def logInfo(entry: LogEntry): Unit = {
    if (log.isInfoEnabled) {
      withLogContext(entry.context) {
        log.info(entry.message)
      }
    }
  }

```

The field `messageWithContext` is constructed twice, one from `entry.context` 
and another one from `entry.message`.

We should improve this.


> Log entry should be constructed only once
> -----------------------------------------
>
>                 Key: SPARK-48744
>                 URL: https://issues.apache.org/jira/browse/SPARK-48744
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 4.0.0
>            Reporter: Gengliang Wang
>            Assignee: Gengliang Wang
>            Priority: Major
>
> In the current implementation:
> ```
> class LogEntry(messageWithContext: => MessageWithContext) {
>   def message: String = mwc.message
>   def context: java.util.HashMap[String, String] = mwc.context
> }
> def logInfo(entry: LogEntry): Unit = {
>   if (log.isInfoEnabled) {
>     withLogContext(entry.context) {
>       log.info(entry.message)
>     }
>   }
> }
> ```
> The field `messageWithContext` is constructed twice, one from `entry.context` 
> and another one from `entry.message`.
> We should improve this.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to