Skip to content

Commit

Permalink
Logger reformat (teragrep#53)
Browse files Browse the repository at this point in the history
* Logger formatting refactored

* Logger formatting refactored

* Refactored loggers to a standard
  • Loading branch information
Nefarious46 authored Mar 19, 2024
1 parent 1430b22 commit 2875678
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 56 deletions.
11 changes: 5 additions & 6 deletions src/main/java/com/teragrep/cfe18/handlers/CaptureController.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public List<CaptureFile> getAllCapture() {
content = @Content)
})
public ResponseEntity<String> newCaptureFile(@RequestBody CaptureFile newCapture) {
LOGGER.info("about to insert <[" + newCapture + "]>");
LOGGER.info("About to insert <[{}]>",newCapture);
try {
CaptureFile c = captureMapper.addNewCaptureFile(
newCapture.getTag(),
Expand All @@ -206,8 +206,7 @@ public ResponseEntity<String> 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");
Expand All @@ -232,7 +231,7 @@ public ResponseEntity<String> newCaptureFile(@RequestBody CaptureFile newCapture
content = @Content)
})
public ResponseEntity<String> newCaptureRelp(@RequestBody CaptureRelp newCapture) {
LOGGER.info("about to insert <[" + newCapture + "]>");
LOGGER.info("About to insert <[{}]>",newCapture);
try {
CaptureRelp c = captureMapper.addNewCaptureRelp(
newCapture.getTag(),
Expand All @@ -243,7 +242,7 @@ public ResponseEntity<String> 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");
Expand All @@ -268,7 +267,7 @@ public ResponseEntity<String> newCaptureRelp(@RequestBody CaptureRelp newCapture
@ApiResponse(responseCode = "500", description = "Internal server error, contact admin", content = @Content)
})
public ResponseEntity<String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ public List<CaptureGroup> getAllCaptureGroup() {
@ApiResponse(responseCode = "500", description = "Internal server error, contact admin", content = @Content)
})
public ResponseEntity<String> 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 {
CaptureGroup c = captureGroupMapper.addNewCaptureGroup(
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());
Expand Down Expand Up @@ -187,7 +187,7 @@ public ResponseEntity<String> newCaptureGroup(@RequestBody CaptureGroup newCaptu
@ApiResponse(responseCode = "500", description = "Internal server error, contact admin", content = @Content)
})
public ResponseEntity<String> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,15 @@ public List<FileCaptureMeta> getAllProcessingType() {

@RequestMapping(path = "/meta/rule", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<String> newFileMeta(@RequestBody FileCaptureMeta newFileCaptureMeta) {
LOGGER.info("about to insert <[" + newFileCaptureMeta + "]>");
LOGGER.info("About to insert <[{}]>",newFileCaptureMeta);
try {
FileCaptureMeta n = fileCaptureMetaMapper.addNewProcessingType(
newFileCaptureMeta.getTemplate(),
newFileCaptureMeta.getRuleset(),
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;
Expand Down Expand Up @@ -176,7 +175,7 @@ public ResponseEntity<String> newFileMeta(@RequestBody FileCaptureMeta newFileCa
// Delete
@RequestMapping(path = "meta/{name}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> 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 {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/teragrep/cfe18/handlers/FlowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public List<Flow> getAllFlow() {

@RequestMapping(path = "", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> 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());
Expand All @@ -106,7 +106,7 @@ public ResponseEntity<String> newFlow(@RequestBody Flow newFlow) {
// Delete
@RequestMapping(path = "/{name}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> removeFlow(@PathVariable("name") String name) {
LOGGER.info("Deleting flow " + name);
LOGGER.info("Deleting flow <[{}]>",name);
try {
flowMapper.deleteFlow(name);
JSONObject j = new JSONObject();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/teragrep/cfe18/handlers/HostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ public List<HostFile> getAllHost() {
//Insert new host with cfe type
@RequestMapping(path = "/file", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<String> 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");
Expand Down Expand Up @@ -186,12 +186,12 @@ public ResponseEntity<String> newHostFile(@RequestBody HostFile newHostFile) {

@RequestMapping(path = "/relp", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<String> 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");
Expand All @@ -218,7 +218,7 @@ public ResponseEntity<String> newHostRelp(@RequestBody HostRelp newHostRelp) {
// Delete
@RequestMapping(path = "/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> removeHost(@PathVariable("id") int id) {
LOGGER.info("Deleting Host " + id);
LOGGER.info("Deleting Host <[{}]>",id);
JSONObject jsonErr = new JSONObject();
jsonErr.put("id", id);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public List<HostGroup> getAllHostGroup() {
// Insert host group with host
@RequestMapping(path = "/group", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<String> 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());
Expand Down Expand Up @@ -146,7 +146,7 @@ public ResponseEntity<String> newHostGroup(@RequestBody HostGroup newHostGroup)
// Delete
@RequestMapping(path = "/group/{name}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public List<InterfaceType> getAllHostMetaInterface() {

@RequestMapping(method = RequestMethod.PUT, path = "/meta", produces = "application/json")
public ResponseEntity<String> addHostMeta(@RequestBody HostMeta newHostMeta) {
LOGGER.info("about to insert <[" + newHostMeta + "]>");
LOGGER.info("About to insert <[{}]>",newHostMeta);
try {
HostMeta hm = hostMetaMapper.addHostMeta(
newHostMeta.getArch(),
Expand All @@ -136,7 +136,7 @@ public ResponseEntity<String> 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");
Expand All @@ -157,12 +157,12 @@ public ResponseEntity<String> addHostMeta(@RequestBody HostMeta newHostMeta) {
// new interface for host metadata
@RequestMapping(method = RequestMethod.PUT, path = "/meta/interface", produces = "application/json")
public ResponseEntity<String> 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");
Expand All @@ -178,12 +178,12 @@ public ResponseEntity<String> addInterface_type(@RequestBody InterfaceType newIn
// new ip address for host metadata
@RequestMapping(path = "/meta/ip", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<String> 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");
Expand All @@ -199,7 +199,7 @@ public ResponseEntity<String> addIpAddress(@RequestBody IPAddress newIpAddress)
// Delete IP
@RequestMapping(path = "/meta/ip/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> removeIp(@PathVariable("id") int id) {
LOGGER.info("Deleting Host " + id);
LOGGER.info("Deleting Host <[{}]>",id);
JSONObject jsonErr = new JSONObject();
jsonErr.put("id", id);
try {
Expand Down Expand Up @@ -227,7 +227,7 @@ public ResponseEntity<String> removeIp(@PathVariable("id") int id) {
// Delete Interface
@RequestMapping(path = "/meta/interface/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> removeInterface(@PathVariable("id") int id) {
LOGGER.info("Deleting Interface " + id);
LOGGER.info("Deleting Interface <[{}]>",id);
JSONObject jsonErr = new JSONObject();
jsonErr.put("id", id);
try {
Expand Down Expand Up @@ -255,7 +255,7 @@ public ResponseEntity<String> removeInterface(@PathVariable("id") int id) {
// Delete HostMeta
@RequestMapping(path = "/meta/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> 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");
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/teragrep/cfe18/handlers/HubController.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ public List<Hub> getAllHub() {
// Insert hub
@RequestMapping(path = "/hub", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<String> 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");
Expand All @@ -145,7 +145,7 @@ public ResponseEntity<String> addNewHub(@RequestBody Hub newHub) {
// Delete
@RequestMapping(path = "/hub/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> removeHub(@PathVariable("id") int id) {
LOGGER.info("Deleting Hub " + id);
LOGGER.info("Deleting Hub <[{}]>",id);
JSONObject jsonErr = new JSONObject();
jsonErr.put("id", id);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public List<Linkage> getAllLinkage() {
// add new g_x_g
@RequestMapping(path = "/linkage", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<String> 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());
Expand All @@ -133,7 +133,7 @@ public ResponseEntity<String> newLinkage(@RequestBody Linkage newLinkage) {
// Delete
@RequestMapping(path = "/linkage/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> removeLinkage(@PathVariable("id") int id) {
LOGGER.info("Deleting Linkage " + id);
LOGGER.info("Deleting Linkage <[{}]>",id);
JSONObject jsonErr = new JSONObject();
jsonErr.put("id", id);
try {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/teragrep/cfe18/handlers/SinkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,20 @@ public ResponseEntity<?> getSink(@PathVariable("id") int id) {
// GET ALL Sinks
@RequestMapping(path = "", method = RequestMethod.GET, produces = "application/json")
public List<Sink> getAllSink() {
LOGGER.info("about to get <[" + sinkMapper.getAllSinks() + "]>");
return sinkMapper.getAllSinks();
}


@RequestMapping(path = "/details", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<String> 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");
Expand Down Expand Up @@ -147,7 +146,7 @@ public ResponseEntity<String> newSink(@RequestBody Sink newSink) {
// Delete
@RequestMapping(path = "/id/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteSink(@PathVariable("id") int id) {
LOGGER.info("Deleting sink " + id);
LOGGER.info("Deleting sink <[{}]>",id);
JSONObject jsonErr = new JSONObject();
jsonErr.put("id", id);
try {
Expand Down
Loading

0 comments on commit 2875678

Please sign in to comment.