From 2875678e84e34789cbd70545bff6b602a21b4ff3 Mon Sep 17 00:00:00 2001 From: Nefarious46 <146811860+Nefarious46@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:32:25 +0200 Subject: [PATCH] Logger reformat (#53) * Logger formatting refactored * Logger formatting refactored * Refactored loggers to a standard --- .../cfe18/handlers/CaptureController.java | 11 +++++------ .../cfe18/handlers/CaptureGroupController.java | 6 +++--- .../handlers/FileCaptureMetaController.java | 7 +++---- .../cfe18/handlers/FlowController.java | 6 +++--- .../cfe18/handlers/HostController.java | 10 +++++----- .../cfe18/handlers/HostGroupController.java | 6 +++--- .../cfe18/handlers/HostMetaController.java | 18 +++++++++--------- .../teragrep/cfe18/handlers/HubController.java | 6 +++--- .../cfe18/handlers/LinkageController.java | 6 +++--- .../cfe18/handlers/SinkController.java | 7 +++---- .../cfe18/handlers/StorageController.java | 18 +++++++++--------- .../controllerTests/HostControllerTest.java | 4 ---- 12 files changed, 49 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/teragrep/cfe18/handlers/CaptureController.java b/src/main/java/com/teragrep/cfe18/handlers/CaptureController.java index c5434a6..56840f5 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/CaptureController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/CaptureController.java @@ -192,7 +192,7 @@ public List getAllCapture() { content = @Content) }) public ResponseEntity newCaptureFile(@RequestBody CaptureFile newCapture) { - LOGGER.info("about to insert <[" + newCapture + "]>"); + LOGGER.info("About to insert <[{}]>",newCapture); try { CaptureFile c = captureMapper.addNewCaptureFile( newCapture.getTag(), @@ -206,8 +206,7 @@ public ResponseEntity newCaptureFile(@RequestBody CaptureFile newCapture newCapture.getTag_path(), newCapture.getCapture_path(), newCapture.getProcessing_type()); - - LOGGER.info("Values returned <[" + c + "]>"); + LOGGER.debug("Values returned <[{}]>",c); JSONObject jsonObjectFile = new JSONObject(); jsonObjectFile.put("id", c.getId()); jsonObjectFile.put("message", "New capture created"); @@ -232,7 +231,7 @@ public ResponseEntity newCaptureFile(@RequestBody CaptureFile newCapture content = @Content) }) public ResponseEntity newCaptureRelp(@RequestBody CaptureRelp newCapture) { - LOGGER.info("about to insert <[" + newCapture + "]>"); + LOGGER.info("About to insert <[{}]>",newCapture); try { CaptureRelp c = captureMapper.addNewCaptureRelp( newCapture.getTag(), @@ -243,7 +242,7 @@ public ResponseEntity newCaptureRelp(@RequestBody CaptureRelp newCapture newCapture.getSource_type(), newCapture.getProtocol(), newCapture.getFlow()); - LOGGER.info("Values returned <[" + c + "]>"); + LOGGER.debug("Values returned <[{}]>",c); JSONObject jsonObjectRelp = new JSONObject(); jsonObjectRelp.put("id", c.getId()); jsonObjectRelp.put("message", "New capture created"); @@ -268,7 +267,7 @@ public ResponseEntity newCaptureRelp(@RequestBody CaptureRelp newCapture @ApiResponse(responseCode = "500", description = "Internal server error, contact admin", content = @Content) }) public ResponseEntity removeCapture(@PathVariable("id") int id) { - LOGGER.info("Deleting capture with id = " + id); + LOGGER.info("Deleting capture with id <[{}]>",id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); jsonErr.put("message", "Unexpected error occurred"); diff --git a/src/main/java/com/teragrep/cfe18/handlers/CaptureGroupController.java b/src/main/java/com/teragrep/cfe18/handlers/CaptureGroupController.java index 471c709..a19a422 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/CaptureGroupController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/CaptureGroupController.java @@ -142,7 +142,7 @@ public List getAllCaptureGroup() { @ApiResponse(responseCode = "500", description = "Internal server error, contact admin", content = @Content) }) public ResponseEntity newCaptureGroup(@RequestBody CaptureGroup newCaptureGroup) { - LOGGER.info("about to insert <[" + newCaptureGroup + "]>"); + LOGGER.info("About to insert <[{}]>",newCaptureGroup); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", 0); try { @@ -150,7 +150,7 @@ public ResponseEntity newCaptureGroup(@RequestBody CaptureGroup newCaptu newCaptureGroup.getCapture_def_group_name(), newCaptureGroup.getCapture_definition_id() ); - LOGGER.info("Values returned <[" + c + "]>"); + LOGGER.debug("Values returned <[{}]>",c); JSONObject jsonObject = new JSONObject(); jsonObject.put("capture_group_id", c.getId()); jsonObject.put("message", "New capture group created with name = " + c.getCapture_def_group_name()); @@ -187,7 +187,7 @@ public ResponseEntity newCaptureGroup(@RequestBody CaptureGroup newCaptu @ApiResponse(responseCode = "500", description = "Internal server error, contact admin", content = @Content) }) public ResponseEntity removeCaptureGroup(@PathVariable("name") String name) { - LOGGER.info("Deleting Capture group " + name); + LOGGER.info("Deleting Capture group <[{}]>", name); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", 0); try { diff --git a/src/main/java/com/teragrep/cfe18/handlers/FileCaptureMetaController.java b/src/main/java/com/teragrep/cfe18/handlers/FileCaptureMetaController.java index d613ad1..bb449d9 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/FileCaptureMetaController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/FileCaptureMetaController.java @@ -131,7 +131,7 @@ public List getAllProcessingType() { @RequestMapping(path = "/meta/rule", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity newFileMeta(@RequestBody FileCaptureMeta newFileCaptureMeta) { - LOGGER.info("about to insert <[" + newFileCaptureMeta + "]>"); + LOGGER.info("About to insert <[{}]>",newFileCaptureMeta); try { FileCaptureMeta n = fileCaptureMetaMapper.addNewProcessingType( newFileCaptureMeta.getTemplate(), @@ -139,8 +139,7 @@ public ResponseEntity newFileMeta(@RequestBody FileCaptureMeta newFileCa newFileCaptureMeta.getName(), newFileCaptureMeta.getInputtype().toString(), newFileCaptureMeta.getInputvalue()); - LOGGER.info("Values returned <[" + n + "]>"); - + LOGGER.debug("Values returned <[{}]>",n); JSONObject jsonObject = new JSONObject(); // ID is never returned from database so null should suffice. String v = null; @@ -176,7 +175,7 @@ public ResponseEntity newFileMeta(@RequestBody FileCaptureMeta newFileCa // Delete @RequestMapping(path = "meta/{name}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeProcessingType(@PathVariable("name") String name) { - LOGGER.info("Deleting processing type " + name); + LOGGER.info("Deleting processing type <[{}]>",name); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", 0); try { diff --git a/src/main/java/com/teragrep/cfe18/handlers/FlowController.java b/src/main/java/com/teragrep/cfe18/handlers/FlowController.java index 0d3eec8..6e69337 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/FlowController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/FlowController.java @@ -87,10 +87,10 @@ public List getAllFlow() { @RequestMapping(path = "", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity newFlow(@RequestBody Flow newFlow) { - LOGGER.info("about to insert <[" + newFlow + "]>"); + LOGGER.info("About to insert <[{}]>",newFlow); try { Flow f = flowMapper.addNewFlow(newFlow.getName()); - LOGGER.info("Values returned <[" + f + "]>"); + LOGGER.debug("Values returned <[{}]>",f); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", f.getId()); jsonObject.put("message", "new flow added with the name = " + f.getName()); @@ -106,7 +106,7 @@ public ResponseEntity newFlow(@RequestBody Flow newFlow) { // Delete @RequestMapping(path = "/{name}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeFlow(@PathVariable("name") String name) { - LOGGER.info("Deleting flow " + name); + LOGGER.info("Deleting flow <[{}]>",name); try { flowMapper.deleteFlow(name); JSONObject j = new JSONObject(); diff --git a/src/main/java/com/teragrep/cfe18/handlers/HostController.java b/src/main/java/com/teragrep/cfe18/handlers/HostController.java index 698ff9f..26c7c73 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/HostController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/HostController.java @@ -152,13 +152,13 @@ public List getAllHost() { //Insert new host with cfe type @RequestMapping(path = "/file", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity newHostFile(@RequestBody HostFile newHostFile) { - LOGGER.info("about to insert <[" + newHostFile + "]>"); + LOGGER.info("About to insert <[{}]>",newHostFile); try { HostFile hf = hostMapper.addHostFile( newHostFile.getMD5(), newHostFile.getFqHost(), newHostFile.getHub_fq()); - LOGGER.info("about to insert <[" + hf + "]>"); + LOGGER.debug("Values returned <[{}]>",hf); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", hf.getId()); jsonObject.put("message", "New host created with cfe type"); @@ -186,12 +186,12 @@ public ResponseEntity newHostFile(@RequestBody HostFile newHostFile) { @RequestMapping(path = "/relp", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity newHostRelp(@RequestBody HostRelp newHostRelp) { - LOGGER.info("about to insert <[" + newHostRelp + "]>"); + LOGGER.info("About to insert <[{}]>",newHostRelp); try { HostRelp hr = hostMapper.addHostRelp( newHostRelp.getMd5(), newHostRelp.getFqHost()); - LOGGER.info("Values returned <[" + hr + "]>"); + LOGGER.debug("Values returned <[{}]>",hr); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", hr.getId()); jsonObject.put("message", "New host created with relp type"); @@ -218,7 +218,7 @@ public ResponseEntity newHostRelp(@RequestBody HostRelp newHostRelp) { // Delete @RequestMapping(path = "/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeHost(@PathVariable("id") int id) { - LOGGER.info("Deleting Host " + id); + LOGGER.info("Deleting Host <[{}]>",id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); try { diff --git a/src/main/java/com/teragrep/cfe18/handlers/HostGroupController.java b/src/main/java/com/teragrep/cfe18/handlers/HostGroupController.java index 0d9d241..e66e496 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/HostGroupController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/HostGroupController.java @@ -111,13 +111,13 @@ public List getAllHostGroup() { // Insert host group with host @RequestMapping(path = "/group", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity newHostGroup(@RequestBody HostGroup newHostGroup) { - LOGGER.info("about to insert <[" + newHostGroup + "]>"); + LOGGER.info("About to insert <[{}]>",newHostGroup); try { HostGroup hg = hostGroupMapper.addNewHostGroup( newHostGroup.getHost_id(), newHostGroup.getHost_group_name() ); - LOGGER.info("Values returned <[" + hg + "]>"); + LOGGER.debug("Values returned <[{}]>",hg); JSONObject jsonObject = new JSONObject(); jsonObject.put("host_group_id", hg.getId()); jsonObject.put("message", "New host group created with name = " + hg.getHost_group_name()); @@ -146,7 +146,7 @@ public ResponseEntity newHostGroup(@RequestBody HostGroup newHostGroup) // Delete @RequestMapping(path = "/group/{name}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeHost(@PathVariable("name") String name) { - LOGGER.info("Deleting Host Group " + name); + LOGGER.info("Deleting Host Group <[{}]>", name); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", 0); try { diff --git a/src/main/java/com/teragrep/cfe18/handlers/HostMetaController.java b/src/main/java/com/teragrep/cfe18/handlers/HostMetaController.java index 1191a08..fdb3633 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/HostMetaController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/HostMetaController.java @@ -126,7 +126,7 @@ public List getAllHostMetaInterface() { @RequestMapping(method = RequestMethod.PUT, path = "/meta", produces = "application/json") public ResponseEntity addHostMeta(@RequestBody HostMeta newHostMeta) { - LOGGER.info("about to insert <[" + newHostMeta + "]>"); + LOGGER.info("About to insert <[{}]>",newHostMeta); try { HostMeta hm = hostMetaMapper.addHostMeta( newHostMeta.getArch(), @@ -136,7 +136,7 @@ public ResponseEntity addHostMeta(@RequestBody HostMeta newHostMeta) { newHostMeta.getOs(), newHostMeta.getRelease_version() ); - LOGGER.info("Values returned <[" + hm + "]>"); + LOGGER.debug("Values returned <[{}]>",hm); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", hm.getId()); jsonObject.put("message", "New host meta added for host"); @@ -157,12 +157,12 @@ public ResponseEntity addHostMeta(@RequestBody HostMeta newHostMeta) { // new interface for host metadata @RequestMapping(method = RequestMethod.PUT, path = "/meta/interface", produces = "application/json") public ResponseEntity addInterface_type(@RequestBody InterfaceType newInterfaceType) { - LOGGER.info("about to insert <[" + newInterfaceType + "]>"); + LOGGER.info("About to insert <[{}]>",newInterfaceType ); try { InterfaceType it = hostMetaMapper.addInterface_type( newInterfaceType.getInterfaceType(), newInterfaceType.getHost_meta_id()); - LOGGER.info("Values returned <[" + it + "]>"); + LOGGER.debug("Values returned <[{}]>",it); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", it.getHost_meta_id()); jsonObject.put("message", "New interface created for host_meta"); @@ -178,12 +178,12 @@ public ResponseEntity addInterface_type(@RequestBody InterfaceType newIn // new ip address for host metadata @RequestMapping(path = "/meta/ip", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity addIpAddress(@RequestBody IPAddress newIpAddress) { - LOGGER.info("about to insert <[" + newIpAddress + "]>"); + LOGGER.info("About to insert <[{}]>",newIpAddress); try { IPAddress ia = hostMetaMapper.addIpAddress( newIpAddress.getHost_meta_id(), newIpAddress.getIpAddress()); - LOGGER.info("Values returned <[" + ia + "]>"); + LOGGER.debug("Values returned <[{}]>",ia); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", ia.getHost_meta_id()); jsonObject.put("message", "New ip address created for host_meta"); @@ -199,7 +199,7 @@ public ResponseEntity addIpAddress(@RequestBody IPAddress newIpAddress) // Delete IP @RequestMapping(path = "/meta/ip/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeIp(@PathVariable("id") int id) { - LOGGER.info("Deleting Host " + id); + LOGGER.info("Deleting Host <[{}]>",id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); try { @@ -227,7 +227,7 @@ public ResponseEntity removeIp(@PathVariable("id") int id) { // Delete Interface @RequestMapping(path = "/meta/interface/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeInterface(@PathVariable("id") int id) { - LOGGER.info("Deleting Interface " + id); + LOGGER.info("Deleting Interface <[{}]>",id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); try { @@ -255,7 +255,7 @@ public ResponseEntity removeInterface(@PathVariable("id") int id) { // Delete HostMeta @RequestMapping(path = "/meta/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeHostMeta(@PathVariable("id") int id) { - LOGGER.info("Deleting Hostmeta " + id); + LOGGER.info("Deleting Hostmeta <[{}]>",id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); jsonErr.put("message", "Unexpected error occurred"); diff --git a/src/main/java/com/teragrep/cfe18/handlers/HubController.java b/src/main/java/com/teragrep/cfe18/handlers/HubController.java index f40fe2a..63ea8a9 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/HubController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/HubController.java @@ -112,13 +112,13 @@ public List getAllHub() { // Insert hub @RequestMapping(path = "/hub", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity addNewHub(@RequestBody Hub newHub) { - LOGGER.info("about to insert <[" + newHub + "]>"); + LOGGER.info("About to insert <[{}]>",newHub); try { Hub h = hubMapper.addHub( newHub.getFqHost(), newHub.getMd5(), newHub.getIp()); - LOGGER.info("Values returned <[" + h + "]>"); + LOGGER.debug("Values returned <[{}]>",h); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", h.getHub_id()); jsonObject.put("message", "New hub created"); @@ -145,7 +145,7 @@ public ResponseEntity addNewHub(@RequestBody Hub newHub) { // Delete @RequestMapping(path = "/hub/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeHub(@PathVariable("id") int id) { - LOGGER.info("Deleting Hub " + id); + LOGGER.info("Deleting Hub <[{}]>",id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); try { diff --git a/src/main/java/com/teragrep/cfe18/handlers/LinkageController.java b/src/main/java/com/teragrep/cfe18/handlers/LinkageController.java index ce6b878..aa6fdcf 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/LinkageController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/LinkageController.java @@ -111,13 +111,13 @@ public List getAllLinkage() { // add new g_x_g @RequestMapping(path = "/linkage", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity newLinkage(@RequestBody Linkage newLinkage) { - LOGGER.info("about to insert <[" + newLinkage + "]>"); + LOGGER.info("About to insert <[{}]>",newLinkage); try { Linkage l = linkageMapper.addLinkage( newLinkage.getHost_group_id(), newLinkage.getCapture_group_id() ); - LOGGER.info("Values returned <[" + l + "]>"); + LOGGER.debug("Values returned <[{}]>",l); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", l.getId()); jsonObject.put("message", "New linkage created for groups = " + l.getCapture_group_name() + " and " + l.getHost_group_name()); @@ -133,7 +133,7 @@ public ResponseEntity newLinkage(@RequestBody Linkage newLinkage) { // Delete @RequestMapping(path = "/linkage/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeLinkage(@PathVariable("id") int id) { - LOGGER.info("Deleting Linkage " + id); + LOGGER.info("Deleting Linkage <[{}]>",id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); try { diff --git a/src/main/java/com/teragrep/cfe18/handlers/SinkController.java b/src/main/java/com/teragrep/cfe18/handlers/SinkController.java index f9346bf..36dac70 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/SinkController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/SinkController.java @@ -104,21 +104,20 @@ public ResponseEntity getSink(@PathVariable("id") int id) { // GET ALL Sinks @RequestMapping(path = "", method = RequestMethod.GET, produces = "application/json") public List getAllSink() { - LOGGER.info("about to get <[" + sinkMapper.getAllSinks() + "]>"); return sinkMapper.getAllSinks(); } @RequestMapping(path = "/details", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity newSink(@RequestBody Sink newSink) { - LOGGER.info("about to insert <[" + newSink + "]>"); + LOGGER.info("About to insert <[{}]>",newSink); try { Sink n = sinkMapper.addNewSink( newSink.getProtocol(), newSink.getIp_address(), newSink.getPort(), newSink.getFlow()); - LOGGER.info("Values returned <[" + n + "]>"); + LOGGER.debug("Values returned <[{}]>",n ); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", n.getId()); jsonObject.put("message", "New sink created"); @@ -147,7 +146,7 @@ public ResponseEntity newSink(@RequestBody Sink newSink) { // Delete @RequestMapping(path = "/id/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity deleteSink(@PathVariable("id") int id) { - LOGGER.info("Deleting sink " + id); + LOGGER.info("Deleting sink <[{}]>",id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); try { diff --git a/src/main/java/com/teragrep/cfe18/handlers/StorageController.java b/src/main/java/com/teragrep/cfe18/handlers/StorageController.java index ab068ba..255a293 100644 --- a/src/main/java/com/teragrep/cfe18/handlers/StorageController.java +++ b/src/main/java/com/teragrep/cfe18/handlers/StorageController.java @@ -148,12 +148,12 @@ public List getStorages() { // New storage with the flow @RequestMapping(path = "/flow", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity addNewStorage(@RequestBody FlowStorage newFlowStorage) { - LOGGER.info("about to insert <[" + newFlowStorage + "]>"); + LOGGER.info("About to insert <[{}]>",newFlowStorage); try { FlowStorage fs = storageMapper.addStorageForFlow( newFlowStorage.getFlow(), newFlowStorage.getStorage_id()); - LOGGER.info("Values returned <[" + fs + "]>"); + LOGGER.debug("Values returned <[{}]>",fs); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", fs.getId()); jsonObject.put("message", "New flow storage created"); @@ -170,12 +170,12 @@ public ResponseEntity addNewStorage(@RequestBody FlowStorage newFlowStor // Link storage to capture @RequestMapping(path = "/capture", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity linkStorageToCapture(@RequestBody CaptureStorage newCaptureStorage) { - LOGGER.info("about to insert <[" + newCaptureStorage + "]>"); + LOGGER.info("About to insert <[{}]>",newCaptureStorage); try { CaptureStorage cs = storageMapper.addStorageForCapture( newCaptureStorage.getCapture_id(), newCaptureStorage.getStorage_id()); - LOGGER.info("Values returned <[" + cs + "]>"); + LOGGER.debug("Values returned <[{}]>",cs); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", cs.getCapture_id()); jsonObject.put("message", "New capture storage created"); @@ -203,12 +203,12 @@ public ResponseEntity linkStorageToCapture(@RequestBody CaptureStorage n // Insert standalone storage @RequestMapping(path = "", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity addStorage(@RequestBody Storage newStorage) { - LOGGER.info("about to insert <[" + newStorage + "]>"); + LOGGER.info("About to insert <[{}]>",newStorage); try { Storage s = storageMapper.addStorage( newStorage.getCfe_type().toString(), newStorage.getTarget_name()); - LOGGER.info("Values returned <[" + s + "]>"); + LOGGER.debug("Values returned <[{}]>",s); JSONObject jsonObject = new JSONObject(); jsonObject.put("id", s.getId()); jsonObject.put("message", "New storage created"); @@ -233,7 +233,7 @@ public ResponseEntity addStorage(@RequestBody Storage newStorage) { // Delete Storage @RequestMapping(path = "/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeStorage(@PathVariable("id") int id) { - LOGGER.info("Deleting Storage " + id); + LOGGER.info("Deleting Storage <[{}]>", id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); try { @@ -261,7 +261,7 @@ public ResponseEntity removeStorage(@PathVariable("id") int id) { // Delete flow storage @RequestMapping(path = "/flow/{flow}/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeFlowStorage(@PathVariable("flow") String flow, @PathVariable("id") int id) { - LOGGER.info("Deleting " + flow + " Storage " + id); + LOGGER.info("Deleting flow Storage with id <[{}]>", id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", id); try { @@ -289,7 +289,7 @@ public ResponseEntity removeFlowStorage(@PathVariable("flow") String flo // Delete capture storage @RequestMapping(path = "/capture/{capture_id}/{storage_id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity removeCaptureStorage(@PathVariable("capture_id") int capture_id, @PathVariable("storage_id") int storage_id) { - LOGGER.info("Deleting capture = " + capture_id + ", Storage " + storage_id); + LOGGER.info("Deleting capture storage with id <[{}]>",storage_id); JSONObject jsonErr = new JSONObject(); jsonErr.put("id", capture_id); try { diff --git a/src/test/java/com/teragrep/cfe18/controllerTests/HostControllerTest.java b/src/test/java/com/teragrep/cfe18/controllerTests/HostControllerTest.java index 67a12eb..7f1bd60 100644 --- a/src/test/java/com/teragrep/cfe18/controllerTests/HostControllerTest.java +++ b/src/test/java/com/teragrep/cfe18/controllerTests/HostControllerTest.java @@ -61,8 +61,6 @@ import org.json.JSONObject; import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtendWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; @@ -214,8 +212,6 @@ public void testInsertCfeHost() throws Exception { // Entity response string String responseString = EntityUtils.toString(entity); - final Logger LOGGER = LoggerFactory.getLogger(HostController.class); - LOGGER.error(responseString); // Parsin respponse as JSONObject JSONObject responseAsJson = new JSONObject(responseString);