|
Download task_047/instruction.md from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_047/instruction.md
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_047/instruction.md
-
curl -L -o instruction.md https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_047/instruction.md
1.94 kB
Implement a pluggable HTTP log service
Extend the supplied Go loganalyzer project. Separate log and tagging rules, application processing, persistence and the net/http interface so processing can be tested with an injected repository. Build and test offline with go test ./....
Interfaces
- Keep
Logwith its string JSON fieldsid,message,level,timestampandtag. - Keep
RepositorywithSave(Log) errorandGet(id string) (Log, bool), and the constructorsNewMemoryRepository(),NewFileRepository(path)andNewRepositoryFromConfig(kind,path)returningRepository. - Keep
GenerateTag(Log) string,NewService(repo) *Service,Service.Process(Log) (Log,error)andNewHandler(repo) http.Handler. Generate a nonempty tag from the log (for example by level); no tagging taxonomy is prescribed. - Run the server with
go run ./cmd/server. Default port is 8081; configurePORT,STORAGE=memory|fileand the file pathLOG_FILEthrough the environment.
Acceptance Checklist
POST /logsaccepts one JSON object with nonemptyid,message,leveland RFC3339timestamp. Generate a tag, save the complete record and return it as JSON with a successful 2xx status. Trailing whitespace is allowed, but extra JSON values or other junk are not.- Malformed JSON or invalid fields return 400, leave no retrievable record, and do not disrupt later valid requests.
GET /log/:idreturns the full stored JSON record and 200 when found, or 404 when missing. Unsupported methods on either route return 405. - Memory storage supports immediate reads; file storage persists records in JSON or CSV and loads them after reopening or restarting the server. Preserve messages of at least 100 KiB in full.
- A failed file write returns an error and leaves no unsaved record in memory. Creating missing parent directories is allowed; an unavailable destination must not give a success response.