Project

General

Profile

Task #26343

Implement logging for web service start and stop events

Added by Sachin Divekar 3 months ago. Updated about 1 month ago.

Status:
Testing
Priority:
Normal
Target version:
-
Start date:
24/03/2025
Due date:
% Done:

100%

Estimated time:

Description

Create a Gin middleware to log web service start and stop events. This middleware should log a "start" and "end" message for each web service call.

#1

Updated by Shuvam Misra 3 months ago

Actually, I'd prefer one log entry, not two, at the end of each WS call, logging details about the call plus the duration.

#2

Updated by Sachin Divekar about 1 month ago

  • Status changed from New to In Progress
#3

Updated by Sachin Divekar about 1 month ago

  • % Done changed from 0 to 100

Written a middleware that accepts a RequestLogger interface

type RequestLogger interface {
    Log(info RequestInfo)
}

and logs request details. Basic testing is done by writing a sample program and sending requests. It logs the following:

type RequestInfo struct {
    Method       string        `json:"method"`
    Path         string        `json:"path"`
    ClientIP     string        `json:"client_ip"`
    StatusCode   int           `json:"status_code"`
    Timestamp    time.Time     `json:"timestamp"` // When the request was received
    Duration     time.Duration `json:"duration"`
    RequestSize  int64         `json:"request_size"`
    ResponseSize int64         `json:"response_size"`
    Query        string        `json:"query,omitempty"`
    UserAgent    string        `json:"user_agent,omitempty"`
    Referer      string        `json:"referer,omitempty"`
    TraceID      string        `json:"trace_id,omitempty"`
    SpanID       string        `json:"span_id,omitempty"`
}
#4

Updated by Sachin Divekar about 1 month ago

  • Status changed from In Progress to Testing

Also available in: Atom PDF