ServeHTTP is a simple JSON endpoint that can report on or change the current logging level. # GET The GET request returns a JSON description of the current logging level like: {"level":"info"} # PUT The PUT request changes the logging level. It is perfectly safe to change the logging level whi
(w http.ResponseWriter, r *http.Request)
| 69 | // |
| 70 | // curl -X PUT localhost:8080/log/level -H "Content-Type: application/json" -d '{"level":"debug"}' |
| 71 | func (lvl AtomicLevel) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 72 | if err := lvl.serveHTTP(w, r); err != nil { |
| 73 | w.WriteHeader(http.StatusInternalServerError) |
| 74 | _, _ = fmt.Fprintf(w, "internal error: %v", err) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func (lvl AtomicLevel) serveHTTP(w http.ResponseWriter, r *http.Request) error { |
| 79 | type errorResponse struct { |