Project

General

Profile

Actions

Feature #4194

closed

[Keep] consistent logging for keepstore requests

Added by Tim Pierce over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Normal
Assigned To:
Radhika Chippada
Category:
Keep
Target version:
Story points:
2.5

Description

Currently, each handler is expected to implement its own logging. As a result, log formats are inconsistent, handlers get written without any logs at all, and at best there is much code repetition.

Instead, the router should implement a generic request/response logging system with the following features.
  • Every transaction uses the same format, e.g., "ipaddr resp_status resp_size elapsed uri err"
  • Individual handlers do not worry about logging or returning error codes -- they just set the response status using http.Error(), http.StatusOK, etc., and let the logging system figure out what to say by inspecting the request and response objects.
Implementation:
  • Perhaps this:
    •     // Tell the built-in HTTP server to direct all requests to the REST
          // router.
          http.Handle("/", MakeRESTRouter())
      
  • ...can be replaced with something like this?
    •     // The built-in HTTP server will pass each request to this function,
          // which forwards the request to the REST router and logs the outcome.
          router := MakeRESTRouter()
          http.HandleFunc("/", func(resp ResponseWriter, req *Request) {
              router.ServeHTTP(resp, req)
              // log stuff here!
          })
      

Subtasks 1 (0 open1 closed)

Task #4542: Review branch: 4194-keep-loggingResolvedTim Pierce11/16/2014Actions
Actions

Also available in: Atom PDF