sqlg3.runtime.SqlTrace Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sqlg3-runtime Show documentation
Show all versions of sqlg3-runtime Show documentation
SQLG is a preprocessor and a library that uses code generation to simplify writing JDBC code
package sqlg3.runtime;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;
/**
* Tracing of SQL statements.
*/
public interface SqlTrace {
static void doTrace(Consumer logger, String header, Supplier> getMessages) {
List messages = getMessages.get();
logger.accept(header);
for (String message : messages) {
logger.accept(message);
}
}
static SqlTrace createDefault(Consumer logger) {
return (ok, time, getMessages) -> {
if (!ok) {
doTrace(logger, "SQL not completed properly", getMessages);
}
};
}
/**
* @param ok false if SQL statement has not completed successfully
* @param time time in milliseconds
*/
void trace(boolean ok, long time, Supplier> getMessages);
}