MCPcopy
hub / github.com/monasticacademy/httptap / NewLogger

Function NewLogger

experiments/goproxy/goproxy-experiment.go:117–132  ·  view source on GitHub ↗
(basepath string)

Source from the content-addressed store, hash-verified

115}
116
117func NewLogger(basepath string) (*HttpLogger, error) {
118 f, err := os.Create(path.Join(basepath, "log"))
119 if err != nil {
120 return nil, err
121 }
122 logger := &HttpLogger{basepath, make(chan *Meta), make(chan error)}
123 go func() {
124 for m := range logger.c {
125 if _, err := m.WriteTo(f); err != nil {
126 log.Println("Can't write meta", err)
127 }
128 }
129 logger.errch <- f.Close()
130 }()
131 return logger, nil
132}
133
134func (logger *HttpLogger) LogResp(resp *http.Response, ctx *goproxy.ProxyCtx) {
135 body := path.Join(logger.path, fmt.Sprintf("%d_resp", ctx.Session))

Callers 1

mainFunction · 0.85

Calls 2

WriteToMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected