Skip to content

Commit

Permalink
chore: p6spy 하이라이트 로깅 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
sjiwon committed Feb 19, 2024
1 parent cf06962 commit e9f9bd2
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.p6spy.engine.logging.Category.STATEMENT
import com.p6spy.engine.spy.appender.MessageFormattingStrategy
import org.hibernate.engine.jdbc.internal.FormatStyle.BASIC
import org.hibernate.engine.jdbc.internal.FormatStyle.DDL
import org.hibernate.engine.jdbc.internal.FormatStyle.HIGHLIGHT
import java.util.Locale.ROOT

class P6SpyFormatter : MessageFormattingStrategy {
Expand All @@ -21,9 +20,9 @@ class P6SpyFormatter : MessageFormattingStrategy {
return "Command -> Execute = ${elapsed}ms || Category = $category || DB Connection ID = $connectionId || URL = $url"
}
if (isStatementDDL(sql, category)) {
return "DDL Query -> Execute = ${elapsed}ms || DB Connection ID = $connectionId || URL = $url ${highlight(DDL.formatter.format(sql))}"
return "DDL Query -> Execute = ${elapsed}ms || DB Connection ID = $connectionId || URL = $url ${DDL.formatter.format(sql)}"
}
return "DML Query -> Execute = ${elapsed}ms || DB Connection ID = $connectionId || URL = $url ${highlight(BASIC.formatter.format(sql))}"
return "DML Query -> Execute = ${elapsed}ms || DB Connection ID = $connectionId || URL = $url ${BASIC.formatter.format(sql)}"
}

private fun isStatementDDL(
Expand All @@ -35,8 +34,6 @@ class P6SpyFormatter : MessageFormattingStrategy {

private fun isDDL(sql: String): Boolean = setOf(CREATE, ALTER, DROP, COMMENT).any { sql.startsWith(it) }

private fun highlight(sql: String?): String = HIGHLIGHT.formatter.format(sql)

companion object {
private const val CREATE: String = "create"
private const val ALTER: String = "alter"
Expand Down

0 comments on commit e9f9bd2

Please sign in to comment.