public class SQLStatementLogger extends PersistenceLogger
directory.xml at DIR_PATH location
because, by default, global logging is disabled.
The object itself allows a bit of configuration: with or without a timestamp and the specific one, using
the simple date format.| Modifier and Type | Field and Description |
|---|---|
private static SQLStatementLogger |
logger
The static singleton instance.
|
| Modifier | Constructor and Description |
|---|---|
private |
SQLStatementLogger()
The private default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static SQLStatementLogger |
getLogger()
Static accessor to singleton.
|
protected <T,U> void |
log(java.lang.String databaseName,
java.lang.String statement,
boolean isFullStatement,
SQLStatementLoggerConfiguration config,
int batchSize,
java.lang.Double profilingTime)
Log something using a
Database as reference. |
private void |
simplify(java.lang.String statement,
java.lang.StringBuilder sb)
Simplifies a statement in order to fit on a single line.
|
getStackMethodParentprivate static final SQLStatementLogger logger
public static SQLStatementLogger getLogger()
SQLStatementLogger singleton instance.protected <T,U> void log(java.lang.String databaseName,
java.lang.String statement,
boolean isFullStatement,
SQLStatementLoggerConfiguration config,
int batchSize,
java.lang.Double profilingTime)
throws java.sql.SQLException
Database as reference. The method use the settings specific to this
database, as previously set. If the LOGGING_ENABLED is not active, this method will not be
called at all.
When called the first time for a specific database, it will query the registry to see whether that
database has the logging logic enabled. This flag will be saved for further calls. It can be
programmatically altered by using setEnabled() API.
T - The statement type.U - Either the argument type or the result type.databaseName - The name of the Database.statement - The statement used.isFullStatement - Flag that denotes whether the statement contains parameter values or not.config - The logging configuration for this database.batchSize - How many SQLs are in this batch.profilingTime - The execution time of the SQL query.java.sql.SQLExceptionprivate void simplify(java.lang.String statement,
java.lang.StringBuilder sb)
statement - The statement to be printed. It eventually takes multiple lines.sb - The StringBuilder to append the result to.