mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-10 05:56:42 +00:00
Fix log endpoint
This commit is contained in:
parent
5c25811561
commit
62f9ca4d4b
@ -20,6 +20,10 @@ func (r *Request) OkJson(object JsonResponse) {
|
|||||||
handleErr(err, r)
|
handleErr(err, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Request) Ok() {
|
||||||
|
r.Ctx.Response.SetStatusCode(204)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Request) Json(object JsonResponse, code int) {
|
func (r *Request) Json(object JsonResponse, code int) {
|
||||||
|
|
||||||
resp, err := json.Marshal(object)
|
resp, err := json.Marshal(object)
|
||||||
|
@ -70,6 +70,8 @@ func (api *WebAPI) LogTrace(r *Request) {
|
|||||||
"scope": entry.Scope,
|
"scope": entry.Scope,
|
||||||
"worker": entry.worker.Id,
|
"worker": entry.worker.Id,
|
||||||
}).WithTime(entry.Time()).Trace(entry.Message)
|
}).WithTime(entry.Time()).Trace(entry.Message)
|
||||||
|
|
||||||
|
r.Ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *WebAPI) LogInfo(r *Request) {
|
func (api *WebAPI) LogInfo(r *Request) {
|
||||||
@ -87,6 +89,8 @@ func (api *WebAPI) LogInfo(r *Request) {
|
|||||||
"scope": entry.Scope,
|
"scope": entry.Scope,
|
||||||
"worker": entry.worker.Id,
|
"worker": entry.worker.Id,
|
||||||
}).WithTime(entry.Time()).Info(entry.Message)
|
}).WithTime(entry.Time()).Info(entry.Message)
|
||||||
|
|
||||||
|
r.Ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *WebAPI) LogWarn(r *Request) {
|
func (api *WebAPI) LogWarn(r *Request) {
|
||||||
@ -104,6 +108,8 @@ func (api *WebAPI) LogWarn(r *Request) {
|
|||||||
"scope": entry.Scope,
|
"scope": entry.Scope,
|
||||||
"worker": entry.worker.Id,
|
"worker": entry.worker.Id,
|
||||||
}).WithTime(entry.Time()).Warn(entry.Message)
|
}).WithTime(entry.Time()).Warn(entry.Message)
|
||||||
|
|
||||||
|
r.Ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *WebAPI) LogError(r *Request) {
|
func (api *WebAPI) LogError(r *Request) {
|
||||||
@ -121,6 +127,8 @@ func (api *WebAPI) LogError(r *Request) {
|
|||||||
"scope": entry.Scope,
|
"scope": entry.Scope,
|
||||||
"worker": entry.worker.Id,
|
"worker": entry.worker.Id,
|
||||||
}).WithTime(entry.Time()).Error(entry.Message)
|
}).WithTime(entry.Time()).Error(entry.Message)
|
||||||
|
|
||||||
|
r.Ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *WebAPI) GetLog(r *Request) {
|
func (api *WebAPI) GetLog(r *Request) {
|
||||||
|
@ -176,7 +176,7 @@ func (c TaskTrackerClient) Log(level storage.LogLevel, message string) error {
|
|||||||
case storage.WARN:
|
case storage.WARN:
|
||||||
levelString = "warn"
|
levelString = "warn"
|
||||||
case storage.INFO:
|
case storage.INFO:
|
||||||
levelString = "panic"
|
levelString = "info"
|
||||||
case storage.TRACE:
|
case storage.TRACE:
|
||||||
levelString = "trace"
|
levelString = "trace"
|
||||||
default:
|
default:
|
||||||
@ -184,6 +184,10 @@ func (c TaskTrackerClient) Log(level storage.LogLevel, message string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
httpResp := c.post("/log/"+levelString, req)
|
httpResp := c.post("/log/"+levelString, req)
|
||||||
|
if httpResp.StatusCode == http.StatusNoContent {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var jsonResp api.JsonResponse
|
var jsonResp api.JsonResponse
|
||||||
err := unmarshalResponse(httpResp, &jsonResp)
|
err := unmarshalResponse(httpResp, &jsonResp)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user