-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b85cf0
commit 8cc6f42
Showing
4 changed files
with
54 additions
and
27 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
openbas-api/src/main/java/io/openbas/rest/collector_frontend_error/LogApi.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.openbas.rest.log; | ||
|
||
import io.openbas.rest.helper.RestBehavior; | ||
import io.openbas.rest.log.form.LogDetailsInput; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class LogApi extends RestBehavior { | ||
|
||
public static final Logger logger = LoggerFactory.getLogger(LogApi.class); | ||
|
||
@PostMapping("/api/logs") | ||
public void logDetails(@RequestBody LogDetailsInput logDetailsInput) { | ||
switch (logDetailsInput.getLevel()) { | ||
case "WARN": | ||
logger.warn( | ||
"Message warn received: {} stacktrace: {} at {}", | ||
logDetailsInput.getMessage(), | ||
logDetailsInput.getStack(), | ||
logDetailsInput.getTimestamp()); | ||
break; | ||
case "INFO": | ||
logger.info( | ||
"Message info received: {} stacktrace: {} at {}", | ||
logDetailsInput.getMessage(), | ||
logDetailsInput.getStack(), | ||
logDetailsInput.getTimestamp()); | ||
break; | ||
case "DEBUG": | ||
logger.debug( | ||
"Message debug received: {} stacktrace: {} at {}", | ||
logDetailsInput.getMessage(), | ||
logDetailsInput.getStack(), | ||
logDetailsInput.getTimestamp()); | ||
break; | ||
default: | ||
logger.error( | ||
"Message error received: {} stacktrace: {} at {}", | ||
logDetailsInput.getMessage(), | ||
logDetailsInput.getStack(), | ||
logDetailsInput.getTimestamp()); | ||
break; | ||
} | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
...rontend_error/form/ErrorDetailsInput.java → ...penbas/rest/log/form/LogDetailsInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package io.openbas.rest.collector_frontend_error.form; | ||
package io.openbas.rest.log.form; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class ErrorDetailsInput { | ||
public class LogDetailsInput { | ||
|
||
private String message; | ||
private String stack; | ||
private String timestamp; | ||
private String level; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters