Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit 0be4126

Browse files
apraovjrDavid Tesar
authored andcommitted
Fix logging for user-java api (#95)
1 parent 3182e31 commit 0be4126

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

apis/user-java/src/main/java/io/swagger/repository/UserRepositoryService.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.stereotype.Service;
99

10+
import java.sql.Timestamp;
11+
1012
@Service
1113
public class UserRepositoryService {
1214

@@ -15,7 +17,10 @@ public class UserRepositoryService {
1517
@Autowired
1618
private UserRepository userRepository;
1719

20+
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
21+
1822
public Profile update(Profile updateEntry) {
23+
long start = System.currentTimeMillis();
1924
Preconditions.checkNotNull(updateEntry, "User profile cannot be null");
2025

2126
LOGGER.info("Updating user profile for user=%s", updateEntry.getId());
@@ -34,13 +39,24 @@ public Profile update(Profile updateEntry) {
3439
existingUser.setRating(updateEntry.getRating() == null ? existingUser.getRating() : updateEntry.getRating());
3540
existingUser.setRating(updateEntry.getRanking() == null ? existingUser.getRanking() : updateEntry.getRanking());
3641

37-
return save(existingUser);
42+
Profile userProfile = save(existingUser);
43+
long end = System.currentTimeMillis();
44+
long timeElapsed = end - start;
45+
46+
LOGGER.info("Update method called: on {} and response time in ms: {}", timestamp, timeElapsed);
47+
return userProfile;
3848
}
3949

4050
public Profile save(Profile newProfile) {
4151
Preconditions.checkNotNull(newProfile, "User profile cannot be null");
42-
LOGGER.info("Saving new user profile for user=%s", newProfile.getId());
43-
return userRepository.save(newProfile);
52+
53+
long start = System.currentTimeMillis();
54+
Profile userProfile = userRepository.save(newProfile);
55+
long end = System.currentTimeMillis();
56+
long timeElapsed = end - start;
57+
58+
LOGGER.info("Save method called: on {} and response time in ms: {}", timestamp, timeElapsed);
59+
return userProfile;
4460
}
4561

4662
private Profile findOne(String Id) {

0 commit comments

Comments
 (0)