|
1 | 1 | package me.zort.sqllib; |
2 | 2 |
|
3 | 3 | import com.google.gson.Gson; |
4 | | -import lombok.AllArgsConstructor; |
5 | | -import lombok.Data; |
6 | | -import lombok.Getter; |
7 | | -import lombok.RequiredArgsConstructor; |
| 4 | +import lombok.*; |
8 | 5 | import me.zort.sqllib.api.ObjectMapper; |
9 | 6 | import me.zort.sqllib.api.Query; |
10 | 7 | import me.zort.sqllib.api.StatementFactory; |
|
41 | 38 | import java.sql.*; |
42 | 39 | import java.util.*; |
43 | 40 | import java.util.concurrent.CopyOnWriteArrayList; |
| 41 | +import java.util.logging.Logger; |
44 | 42 |
|
45 | 43 | /** |
46 | 44 | * Main database client object implementation. |
@@ -69,6 +67,8 @@ public class SQLDatabaseConnectionImpl extends SQLDatabaseConnection { |
69 | 67 | @ApiStatus.Experimental |
70 | 68 | private final transient StatementMappingResultAdapter mappingResultAdapter; |
71 | 69 | private transient ObjectMapper objectMapper; |
| 70 | + @Setter |
| 71 | + private transient Logger logger; |
72 | 72 |
|
73 | 73 | /** |
74 | 74 | * Constructs new instance of this implementation with default |
@@ -101,6 +101,7 @@ public SQLDatabaseConnectionImpl(SQLConnectionFactory connectionFactory, @Nullab |
101 | 101 | this.objectMapper = new DefaultObjectMapper(this); |
102 | 102 | this.mappingFactory = new DefaultStatementMappingFactory(); |
103 | 103 | this.mappingResultAdapter = new DefaultResultAdapter(); |
| 104 | + this.logger = Logger.getGlobal(); |
104 | 105 |
|
105 | 106 | // Default backup value resolvers. |
106 | 107 | registerBackupValueResolver(new LinkedOneFieldResolver()); |
@@ -470,9 +471,7 @@ public UpsertQuery save(Object obj) { |
470 | 471 | } |
471 | 472 |
|
472 | 473 | public void debug(String message) { |
473 | | - if(options.isDebug()) { |
474 | | - System.out.println(message); |
475 | | - } |
| 474 | + if(options.isDebug()) logger.info(message); |
476 | 475 | } |
477 | 476 |
|
478 | 477 | @Override |
@@ -513,7 +512,7 @@ private static class DefaultStatementFactory implements StatementFactory<Prepare |
513 | 512 | public PreparedStatement prepare(Connection connection) throws SQLException { |
514 | 513 | String queryString = query.getAncestor().buildQuery(); |
515 | 514 |
|
516 | | - Logger.debug(connection, "Query: " + queryString); |
| 515 | + LocalLogger.debug(connection, "Query: " + queryString); |
517 | 516 | return connection.prepareStatement(queryString); |
518 | 517 | } |
519 | 518 | } |
|
0 commit comments