Skip to content

Commit

Permalink
Highlight Hibernate generated SQL queries
Browse files Browse the repository at this point in the history
This is done by default when quarkus.hibernate-orm.log.sql
is set to true, but it can be controlled explicitly via
quarkus.hibernate-orm.log.highlight-sql
  • Loading branch information
geoand committed Jun 4, 2024
1 parent d74530b commit 66cffe5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ private static void injectRuntimeConfiguration(HibernateOrmRuntimeConfigPersiste
if (persistenceUnitConfig.log().formatSql()) {
runtimeSettingsBuilder.put(AvailableSettings.FORMAT_SQL, "true");
}

if (persistenceUnitConfig.log().highlightSql()) {
runtimeSettingsBuilder.put(AvailableSettings.HIGHLIGHT_SQL, "true");
}
}

if (persistenceUnitConfig.log().jdbcWarnings().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ interface HibernateOrmConfigPersistenceUnitLog {
@WithDefault("true")
boolean formatSql();

/**
* Highlight the SQL logs if SQL log is enabled
*/
@WithDefault("true")
boolean highlightSql();

/**
* Whether JDBC warnings should be collected and logged.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ private static void injectRuntimeConfiguration(HibernateOrmRuntimeConfigPersiste
if (persistenceUnitConfig.log().formatSql()) {
runtimeSettingsBuilder.put(AvailableSettings.FORMAT_SQL, "true");
}

if (persistenceUnitConfig.log().highlightSql()) {
runtimeSettingsBuilder.put(AvailableSettings.HIGHLIGHT_SQL, "true");
}
}

if (persistenceUnitConfig.log().jdbcWarnings().isPresent()) {
Expand Down

0 comments on commit 66cffe5

Please sign in to comment.