Skip to content

Commit a3ebfb7

Browse files
authored
[APIS-1104] Ignore the logFile property and move driver logs to java.util.logging (#88)
http://jira.cubrid.org/browse/APIS-1104
1 parent becb272 commit a3ebfb7

5 files changed

Lines changed: 19 additions & 266 deletions

File tree

‎src/jdbc/cubrid/jdbc/driver/ConnectionProperties.java‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,14 @@ boolean validateValue(Object o) {
364364
}
365365

366366
BooleanConnectionProperty logOnException =
367-
new BooleanConnectionProperty("logOnException", false);
367+
new BooleanConnectionProperty("logOnException", true);
368368

369369
BooleanConnectionProperty logSlowQueries =
370370
new BooleanConnectionProperty("logSlowQueries", false);
371371

372372
IntegerConnectionProperty slowQueryThresholdMillis =
373373
new IntegerConnectionProperty("slowQueryThresholdMillis", 60000, 0, Integer.MAX_VALUE);
374374

375-
StringConnectionProperty logFile = new StringConnectionProperty("logFile", "cubrid_jdbc.log");
376-
377375
CharSetConnectionProperty charSet =
378376
new CharSetConnectionProperty("charSet", System.getProperty("file.encoding"));
379377

@@ -445,10 +443,6 @@ public int getSlowQueryThresholdMillis() {
445443
return slowQueryThresholdMillis.getValueAsInteger();
446444
}
447445

448-
public String getLogFile() {
449-
return logFile.getValueAsString();
450-
}
451-
452446
public String getCharSet() {
453447
return charSet.getValueAsString();
454448
}

‎src/jdbc/cubrid/jdbc/jci/UClientSideConnection.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public UClientSideConnection(
102102
}
103103

104104
public void tryConnect() throws CUBRIDException {
105-
initLogger();
106105
try {
107106
if (connectionProperties.getUseLazyConnection()) {
108107
needReconnection = true;

‎src/jdbc/cubrid/jdbc/jci/UConnection.java‎

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import cubrid.jdbc.driver.CUBRIDDriver;
4545
import cubrid.jdbc.driver.CUBRIDXid;
4646
import cubrid.jdbc.driver.ConnectionProperties;
47-
import cubrid.jdbc.log.BasicLogger;
48-
import cubrid.jdbc.log.Log;
4947
import cubrid.jdbc.net.BrokerHandler;
5048
import cubrid.sql.CUBRIDOID;
5149
import java.io.DataOutputStream;
@@ -56,6 +54,8 @@
5654
import java.text.SimpleDateFormat;
5755
import java.util.Date;
5856
import java.util.Vector;
57+
import java.util.logging.Level;
58+
import java.util.logging.Logger;
5959
import javax.transaction.xa.Xid;
6060

6161
public abstract class UConnection {
@@ -215,8 +215,9 @@ public abstract class UConnection {
215215
driverInfossl[9] = 0; // reserved
216216
}
217217

218+
private static final Logger LOGGER = Logger.getLogger(UConnection.class.getName());
219+
218220
protected UError errorHandler;
219-
protected Log log;
220221

221222
protected ConnectionProperties connectionProperties = new ConnectionProperties();
222223
protected CUBRIDConnection cubridcon;
@@ -1392,19 +1393,6 @@ void cancel() throws UJciException, IOException {
13921393
/*
13931394
* logger
13941395
*/
1395-
protected Log getLogger() {
1396-
if (log == null) {
1397-
log = new BasicLogger(connectionProperties.getLogFile());
1398-
}
1399-
return log;
1400-
}
1401-
1402-
protected void initLogger() {
1403-
if (connectionProperties.getLogOnException() || connectionProperties.getLogSlowQueries()) {
1404-
log = getLogger();
1405-
}
1406-
}
1407-
14081396
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
14091397

14101398
public void logSlowQuery(long begin, long end, String sql, UBindParameter p) {
@@ -1417,6 +1405,10 @@ public void logSlowQuery(long begin, long end, String sql, UBindParameter p) {
14171405
return;
14181406
}
14191407

1408+
if (!LOGGER.isLoggable(Level.FINEST)) {
1409+
return;
1410+
}
1411+
14201412
StringBuffer b = new StringBuffer();
14211413
b.append("SLOW QUERY\n");
14221414
b.append(String.format("[CAS INFO]\n%s:%d, %d, %d\n", casIp, casPort, casId, casProcessId));
@@ -1434,9 +1426,7 @@ public void logSlowQuery(long begin, long end, String sql, UBindParameter p) {
14341426
b.append('\n');
14351427
}
14361428

1437-
synchronized (this) {
1438-
getLogger().logInfo(b.toString());
1439-
}
1429+
LOGGER.log(Level.FINEST, b.toString());
14401430
}
14411431

14421432
/*
@@ -1930,17 +1920,17 @@ public void setConnectionProperties(ConnectionProperties connProperties) {
19301920

19311921
public UJciException createJciException(int err) {
19321922
UJciException e = new UJciException(err);
1933-
if (connectionProperties == null || !connectionProperties.getLogOnException()) {
1923+
if (connectionProperties == null
1924+
|| !connectionProperties.getLogOnException()
1925+
|| !LOGGER.isLoggable(Level.FINE)) {
19341926
return e;
19351927
}
19361928

19371929
StringBuffer b = new StringBuffer();
19381930
b.append("DUMP EXCEPTION\n");
19391931
b.append("[JCI EXCEPTION]");
19401932

1941-
synchronized (this) {
1942-
getLogger().logInfo(b.toString(), e);
1943-
}
1933+
LOGGER.log(Level.FINE, b.toString(), e);
19441934
return e;
19451935
}
19461936

@@ -1951,17 +1941,18 @@ public UJciException createJciException(int err, int indicator, int srv_err, Str
19511941
}
19521942

19531943
public void logException(Throwable t) {
1954-
if (connectionProperties == null || !connectionProperties.getLogOnException()) {
1944+
if (t == null
1945+
|| connectionProperties == null
1946+
|| !connectionProperties.getLogOnException()
1947+
|| !LOGGER.isLoggable(Level.FINE)) {
19551948
return;
19561949
}
19571950

19581951
StringBuffer b = new StringBuffer();
19591952
b.append("DUMP EXCEPTION\n");
19601953
b.append("[" + t.getClass().getName() + "]");
19611954

1962-
synchronized (this) {
1963-
getLogger().logInfo(b.toString(), t);
1964-
}
1955+
LOGGER.log(Level.FINE, b.toString(), t);
19651956
}
19661957

19671958
public boolean isActive() {

‎src/jdbc/cubrid/jdbc/log/BasicLogger.java‎

Lines changed: 0 additions & 173 deletions
This file was deleted.

‎src/jdbc/cubrid/jdbc/log/Log.java‎

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)