hmis-tools / hmis-api-server

Version 2 of OpenHMIS
Mozilla Public License 2.0
15 stars 11 forks source link

Further abstract the internal logging code. #76

Open kfogel opened 8 years ago

kfogel commented 8 years ago

The code to do informational logging (see the commit 634fcbe5 merge) is a bit repetitive and could be further abstracted. Basically, we should create src/main/java/org/openhmis/util/LogUtil.java providing a new a LogUtil class, with at least these three methods:

public static logNamedEntity(String method, String endpoint, Int id) { ... }
public static logCreation(String method, String endpoint, Int newId { ... }
public static logResultSet(String method, String endpoint, Int numResults) { ... }

corresponding respectively to:

log.info("GET /clients/" + clientId);
log.info("POST /clients (new id: " +  newClientId + ")");
log.info("GET /clients (" + clientList.size + " results)");

(Well, we might also need a method or two to handle authn event logging specially.)

Then we could add more methods as we need them, and be assured that our log format would always be consistent.