Skip to content

Commit 0d6d6f7

Browse files
committed
Fix logging ms
1 parent 17913a0 commit 0d6d6f7

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

fj-core/src/main/java/org/fugerit/java/core/db/dao/DAOHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.List;
2929

3030
import org.fugerit.java.core.log.LogObject;
31+
import org.fugerit.java.core.util.checkpoint.CheckpointUtils;
3132
import org.slf4j.Logger;
3233

3334
public class DAOHelper {
@@ -40,7 +41,8 @@ public static void setAll( String queryId, PreparedStatement ps, FieldList field
4041
np++;
4142
int param = (k+1);
4243
Field f = fields.getField(k);
43-
log.debug( "queryId:'{}', setAll() Setting param (ng1) : '{}'", queryId, "n. "+param+", value: "+String.valueOf( f ) );
44+
long startTime = System.currentTimeMillis();
45+
log.debug( "queryId:'{}', setAll() Setting param (ng1) : '{}'", queryId, "n. "+param+", value: "+String.valueOf( f )+" (set time : '"+CheckpointUtils.formatTimeDiffMillis( startTime, System.currentTimeMillis() )+"')" );
4446
f.setField(ps, param);
4547
k++;
4648
}

fj-core/src/main/java/org/fugerit/java/core/db/daogen/BasicDAOHelper.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ public void loadAllHelper( List<T> l, String query, FieldList fields, RSExtracto
9494
int i=0;
9595
try ( PreparedStatement ps = conn.prepareStatement( query ) ) {
9696
DAOHelper.setAll( queryId, ps, fields , log );
97+
long executeStart = System.currentTimeMillis();
9798
try ( ResultSet rs = ps.executeQuery() ) {
98-
log.debug("queryId:'{}', loadAll query execute end time : '{}'", queryId, CheckpointUtils.formatTimeDiff(startTime, System.currentTimeMillis()) );
99+
long executeEnd = System.currentTimeMillis();
100+
log.debug("queryId:'{}', loadAll query execute end time : '{}'", queryId, CheckpointUtils.formatTimeDiffMillis(executeStart, executeEnd ) );
99101
while (rs.next()) {
100102
l.add( re.extractNext( rs ) );
101103
i++;
102104
}
103-
log.debug("queryId:'{}', loadAll query result end time : '{}'", queryId, CheckpointUtils.formatTimeDiff(startTime, System.currentTimeMillis()) );
105+
log.debug("queryId:'{}', loadAll query result set end time : '{}'", queryId, CheckpointUtils.formatTimeDiffMillis( executeEnd, System.currentTimeMillis()) );
106+
log.debug("queryId:'{}', loadAll query total end time : '{}'", queryId, CheckpointUtils.formatTimeDiffMillis( startTime, System.currentTimeMillis()) );
104107
}
105108
} catch (SQLException e) {
106109
throw (new DAOException( e.getMessage()+"[query:"+query+",queryId:"+queryId+",record:"+i+"]", e ));
@@ -123,8 +126,10 @@ public int update( QueryHelper queryHelper ) throws DAOException {
123126
Connection conn = this.daoContext.getConnection();
124127
try ( PreparedStatement ps = conn.prepareStatement( query ) ) {
125128
DAOHelper.setAll( queryId, ps, fields , log );
129+
long executeStart = System.currentTimeMillis();
126130
res = ps.executeUpdate();
127-
log.debug("queryId:'{}', update query execute end time : '{}'", queryId, CheckpointUtils.formatTimeDiff(startTime, System.currentTimeMillis()) );
131+
log.debug("queryId:'{}', update query execute end time : '{}'", queryId, CheckpointUtils.formatTimeDiffMillis(executeStart, System.currentTimeMillis()) );
132+
log.debug("queryId:'{}', update total time : '{}'", queryId, CheckpointUtils.formatTimeDiffMillis(startTime, System.currentTimeMillis()) );
128133
} catch (SQLException e) {
129134
throw (new DAOException( e.getMessage()+"[query:"+query+",queryId:"+queryId+"]", e ));
130135
}

fj-core/src/main/java/org/fugerit/java/core/util/checkpoint/CheckpointUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ public static String formatTimeDiff( long start, long end ) {
1010
return formatTimeDiff( end-start );
1111
}
1212

13+
public static String formatTimeDiffMillis( long start, long end ) {
14+
return String.valueOf(end-start)+" ms";
15+
}
16+
1317
}

0 commit comments

Comments
 (0)