Main class for running application: com.example.logproject.LogProjectApplication
host: http://localhost:8080/h2-ui/
url: jdbc:h2:mem:logdb
username: sa
password:
-
Function readAndSave
Method: POST
Endpoint: http://localhost:8080/log/read_log
JSON:
{
"path": “{path to the file}”
} -
Function get log by level
Method: GET
Endpoint: http://localhost:8080/log/get_by_loglevel/{page}/{size}/{LEVEL} \ -
Function get log by message
Method: GET
Endpoint: http://localhost:8080/log/message/{message} \ -
Function get log by date
Method: get
Endpoint: http://localhost:8080/log/get_by_datetime
JSON:
{
"startDate": "2021-01-26 19:20:34.298",
"endDate": "2021-01-28 22:12:43.405"
}
{ "info": { "_postman_id": "0ed336f4-9d70-45c2-a5aa-43ee061704d1", "name": "log", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "6048457" }, "item": [ { "name": "readAndSave", "request": { "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\n "path": "/Users/rayalekseev/Downloads/standard.log" \n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "http://localhost:8080/log/read_log", "protocol": "http", "host": [ "localhost" ], "port": "8080", "path": [ "log", "read_log" ] } }, "response": [] }, { "name": "getByLogLevel", "request": { "method": "GET", "header": [], "url": { "raw": "http://localhost:8080/log/get_by_loglevel/2/3/INFO", "protocol": "http", "host": [ "localhost" ], "port": "8080", "path": [ "log", "get_by_loglevel", "2", "3", "INFO" ] } }, "response": [] }, { "name": "getByMessage", "request": { "method": "GET", "header": [], "url": { "raw": "http://localhost:8080/log/message/restartedMain", "protocol": "http", "host": [ "localhost" ], "port": "8080", "path": [ "log", "message", "restartedMain" ] } }, "response": [] }, { "name": "getByDateTimeBetween", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { "method": "GET", "header": [], "body": { "mode": "raw", "raw": "{\n "startDate": "2021-01-26 19:20:34.298",\n "endDate": "2021-01-28 22:12:43.405"\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "http://localhost:8080/log/get_by_datetime", "protocol": "http", "host": [ "localhost" ], "port": "8080", "path": [ "log", "get_by_datetime" ] } }, "response": [] } ] }
- Using reactive non-blocking API for DB, like r2dbc. That allow to work with DB not only with one thread per connection. Integration in Spring - Spring Data R2DBC.
- Adding one addiional column in DB timestamp that represent log creation timestamp and add new function to API for searching.
Add index to this column and add partions by this column. EXAMPLE:
CREATE UNIQUE INDEX LOGS_CREATION_DATE_INDEX ON LOGS (TIMESTAMP ASC) ALTER TABLE LOGS ADD PARTITION {generate name} VALUES LESS THAN ({choose date})
- Adding pagination for all needed functions. Not only for "get by level"
- Parsing log row using regular expression (not realised, not unnecessary)
- Add tests !!!