All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sqlg3.runtime.SqlTrace Maven / Gradle / Ivy

Go to download

SQLG is a preprocessor and a library that uses code generation to simplify writing JDBC code

There is a newer version: 3.1
Show newest version
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);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy