| 1 |
public void infoSQL(String sql, String params, long count, long time) { |
| 2 |
if (!isEnabled(TraceSystem.INFO)) { |
| 3 |
return; |
| 4 |
} |
| 5 |
StringBuilder buff = new StringBuilder(sql.length() + params.length() + 20); |
| 6 |
buff.append(lineSeparator).append("/*SQL"); |
| 7 |
boolean space = false; |
| 8 |
if (params.length() > 0) { |
| 9 |
// This looks like a bug, but it is intentional: |
| 10 |
// If there are no parameters, the SQL statement is |
| 11 |
// the rest of the line. If there are parameters, they |
| 12 |
// are appended at the end of the line. Knowing the size |
| 13 |
// of the statement simplifies separating the SQL statement |
| 14 |
// from the parameters (no need to parse). |
| 15 |
space = true; |
| 16 |
buff.append(" l:").append(sql.length()); |
| 17 |
} |
| 18 |
if (count > 0) { |
| 19 |
space = true; |
| 20 |
buff.append(" #:").append(count); |
| 21 |
} |
| 22 |
if (time > 0) { |
| 23 |
space = true; |
| 24 |
buff.append(" t:").append(time); |
| 25 |
} |
| 26 |
if (!space) { |
| 27 |
buff.append(' '); |
| 28 |
} |
| 29 |
buff.append("*/"); |
| 30 |
StringUtils.javaEncode(sql, buff, false); |
| 31 |
StringUtils.javaEncode(params, buff, false); |
| 32 |
buff.append(';'); |
| 33 |
sql = buff.toString(); |
| 34 |
traceWriter.write(TraceSystem.INFO, module, sql, null); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Write Java source code with trace level DEBUG to the trace system. |
| 39 |
* |
| 40 |
* @param java the source code |
| 41 |
*/ |