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 Type
    Method
    Description
    boolean
    Returns true if statement logging is enabled.
    void
    logAlsoSelect(int rowCount)
    Logs a select count continuation line for the statement whose header was already logged.
    void
    logAlsoUpdate(int rowCount)
    Logs an update count continuation line for the statement whose header was already logged.
    void
    logMessage(String message)
    Logs an arbitrary message, such as DDL, PK-generation SQL, or adapter-detection notes.
    void
    logQueryError(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 trailing time_ms:N block with the time elapsed until the failure.
    void
    logSelect(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 trailing time_ms:N block with the statement's execution time.
    void
    Logs a transaction commit boundary (emitted at DEBUG level).
    void
    Logs a transaction rollback boundary (emitted at DEBUG level).
    void
    Logs a transaction start boundary (emitted at DEBUG level).
    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 a generated:[...] block listing any database-generated keys, and a trailing time_ms:N block 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

      void logSelect(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 trailing time_ms:N block with the statement's execution time.
      Parameters:
      statement - the translated statement carrying SQL and bindings
      rowCount - the number of selected rows
      durationMillis - 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 a generated:[...] block listing any database-generated keys, and a trailing time_ms:N block with the statement's execution time.
      Parameters:
      statement - the translated statement carrying SQL and bindings
      rowCount - the number of updated rows
      generatedKeys - the database-generated keys of the inserted rows, or an empty list if none
      durationMillis - the statement's execution time in milliseconds
    • logQueryError

      void logQueryError(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 trailing time_ms:N block with the time elapsed until the failure.
      Parameters:
      statement - the translated statement carrying SQL and bindings
      error - the exception thrown while executing the statement
      durationMillis - 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

      void logMessage(String message)
      Logs an arbitrary message, such as DDL, PK-generation SQL, or adapter-detection notes.