Package org.apache.cayenne.log
Interface SQLLogger
- All Known Implementing Classes:
NoopSQLLogger,Slf4jSQLLogger
public interface SQLLogger
A logging service used by Cayenne to output database interactions as compact, single-line messages.
- Since:
- 5.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if statement logging is enabled.voidlogAlsoSelect(int rowCount) Logs a select count continuation line for the statement whose header was already logged.voidlogAlsoUpdate(int rowCount) Logs an update count continuation line for the statement whose header was already logged.voidlogMessage(String message) Logs an arbitrary message, such as DDL, PK-generation SQL, or adapter-detection notes.voidlogQueryError(TranslatedStatement statement, Throwable error, long durationMillis) Logs, at the ERROR level, the statement that was in progress when a query exception occurred: SQL +bind:[...]+ the error message, followed by a trailingtime_ms:Nblock with the time elapsed until the failure.voidlogSelect(TranslatedStatement statement, int rowCount, long durationMillis) Logs the main line for a statement that returned a result set: SQL +bind:[...]+selected:N, followed by a trailingtime_ms:Nblock with the statement's execution time.voidLogs a transaction commit boundary (emitted at DEBUG level).voidLogs a transaction rollback boundary (emitted at DEBUG level).voidLogs a transaction start boundary (emitted at DEBUG level).voidlogUpdate(TranslatedStatement statement, int rowCount, List<? extends Map<String, ?>> generatedKeys, long durationMillis) Logs the main line for a statement that performed an update: SQL +bind:[...]+updated:N, optionally followed by agenerated:[...]block listing any database-generated keys, and a trailingtime_ms:Nblock with the statement's execution time.
-
Method Details
-
isEnabled
boolean isEnabled()Returns true if statement logging is enabled. Callers should skip the work of assembling results when this returns false. -
logSelect
Logs the main line for a statement that returned a result set: SQL +bind:[...]+selected:N, followed by a trailingtime_ms:Nblock with the statement's execution time.- Parameters:
statement- the translated statement carrying SQL and bindingsrowCount- the number of selected rowsdurationMillis- the statement's execution time in milliseconds
-
logUpdate
void logUpdate(TranslatedStatement statement, int rowCount, List<? extends Map<String, ?>> generatedKeys, long durationMillis) Logs the main line for a statement that performed an update: SQL +bind:[...]+updated:N, optionally followed by agenerated:[...]block listing any database-generated keys, and a trailingtime_ms:Nblock with the statement's execution time.- Parameters:
statement- the translated statement carrying SQL and bindingsrowCount- the number of updated rowsgeneratedKeys- the database-generated keys of the inserted rows, or an empty list if nonedurationMillis- the statement's execution time in milliseconds
-
logQueryError
Logs, at the ERROR level, the statement that was in progress when a query exception occurred: SQL +bind:[...]+ the error message, followed by a trailingtime_ms:Nblock with the time elapsed until the failure.- Parameters:
statement- the translated statement carrying SQL and bindingserror- the exception thrown while executing the statementdurationMillis- the time in milliseconds elapsed until the failure
-
logAlsoSelect
void logAlsoSelect(int rowCount) Logs a select count continuation line for the statement whose header was already logged. -
logAlsoUpdate
void logAlsoUpdate(int rowCount) Logs an update count continuation line for the statement whose header was already logged. -
logTransactionStart
void logTransactionStart()Logs a transaction start boundary (emitted at DEBUG level). -
logTransactionCommit
void logTransactionCommit()Logs a transaction commit boundary (emitted at DEBUG level). -
logTransactionRollback
void logTransactionRollback()Logs a transaction rollback boundary (emitted at DEBUG level). -
logMessage
Logs an arbitrary message, such as DDL, PK-generation SQL, or adapter-detection notes.
-