public void infoSQL(String sql, String params, long count, long time) { if (!isEnabled(TraceSystem.INFO)) { return; } StringBuilder buff = new StringBuilder(sql.length() + params.length() + 20); buff.append(lineSeparator).append("/*SQL"); boolean space = false; if (params.length() > 0) { // This looks like a bug, but it is intentional: // If there are no parameters, the SQL statement is // the rest of the line. If there are parameters, they // are appended at the end of the line. Knowing the size // of the statement simplifies separating the SQL statement // from the parameters (no need to parse). space = true; buff.append(" l:").append(sql.length()); } if (count > 0) { space = true; buff.append(" #:").append(count); } if (time > 0) { space = true; buff.append(" t:").append(time); } if (!space) { buff.append(' '); } buff.append("*/"); StringUtils.javaEncode(sql, buff, false); StringUtils.javaEncode(params, buff, false); buff.append(';'); sql = buff.toString(); traceWriter.write(TraceSystem.INFO, module, sql, null); } /** * Write Java source code with trace level DEBUG to the trace system. * * @param java the source code */