MCPcopy Index your code
hub / github.com/coder/coder / HandleHTTPDebugLogs

Method HandleHTTPDebugLogs

agent/agent.go:2157–2175  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

2155}
2156
2157func (a *agent) HandleHTTPDebugLogs(w http.ResponseWriter, r *http.Request) {
2158 logPath := filepath.Join(a.logDir, "coder-agent.log")
2159 f, err := os.Open(logPath)
2160 if err != nil {
2161 a.logger.Error(r.Context(), "open agent log file", slog.Error(err), slog.F("path", logPath))
2162 w.WriteHeader(http.StatusInternalServerError)
2163 _, _ = fmt.Fprintf(w, "could not open log file: %s", err)
2164 return
2165 }
2166 defer f.Close()
2167
2168 // Limit to 10MiB.
2169 w.WriteHeader(http.StatusOK)
2170 _, err = io.Copy(w, io.LimitReader(f, 10*1024*1024))
2171 if err != nil && !errors.Is(err, io.EOF) {
2172 a.logger.Error(r.Context(), "read agent log file", slog.Error(err))
2173 return
2174 }
2175}
2176
2177func (a *agent) HTTPDebug() http.Handler {
2178 r := chi.NewRouter()

Callers

nothing calls this directly

Calls 7

ContextMethod · 0.65
CloseMethod · 0.65
CopyMethod · 0.65
OpenMethod · 0.45
ErrorMethod · 0.45
WriteHeaderMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected