本文整理汇总了Golang中github.com/zenazn/goji/web/mutil.WriterProxy.Status方法的典型用法代码示例。如果您正苦于以下问题:Golang WriterProxy.Status方法的具体用法?Golang WriterProxy.Status怎么用?Golang WriterProxy.Status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zenazn/goji/web/mutil.WriterProxy
的用法示例。
在下文中一共展示了WriterProxy.Status方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: logEndOfRequest
func logEndOfRequest(ctx context.Context, duration time.Duration, mw mutil.WriterProxy) {
log.Ctx(ctx).WithFields(log.F{
"status": mw.Status(),
"bytes": mw.BytesWritten(),
"duration": duration,
}).Info("Finished request")
}
示例2: printResponse
func (l *Logger) printResponse(w mutil.WriterProxy, delta time.Duration) {
var buf bytes.Buffer
buf.WriteString("Returning HTTP ")
status := w.Status()
if status < 200 {
colorWrite(&buf, bBlue, "%03d", status)
} else if status < 300 {
colorWrite(&buf, bGreen, "%03d", status)
} else if status < 400 {
colorWrite(&buf, bCyan, "%03d", status)
} else if status < 500 {
colorWrite(&buf, bYellow, "%03d", status)
} else {
colorWrite(&buf, bRed, "%03d", status)
}
buf.WriteString(" in ")
if delta < FastResponse {
colorWrite(&buf, nGreen, "%s", delta.String())
} else if delta < AcceptableResponse {
colorWrite(&buf, nYellow, "%s", delta.String())
} else {
colorWrite(&buf, nRed, "%s", delta.String())
}
log.Print(buf.String())
}
示例3: printEnd
func printEnd(reqID string, w mutil.WriterProxy, dt time.Duration) {
var buf bytes.Buffer
if reqID != "" {
cW(&buf, bBlack, "[%s] ", reqID)
}
buf.WriteString("Returning ")
status := w.Status()
if status < 200 {
cW(&buf, bBlue, "%03d", status)
} else if status < 300 {
cW(&buf, bGreen, "%03d", status)
} else if status < 400 {
cW(&buf, bCyan, "%03d", status)
} else if status < 500 {
cW(&buf, bYellow, "%03d", status)
} else {
cW(&buf, bRed, "%03d", status)
}
buf.WriteString(" in ")
if dt < 500*time.Millisecond {
cW(&buf, nGreen, "%s", dt)
} else if dt < 5*time.Second {
cW(&buf, nYellow, "%s", dt)
} else {
cW(&buf, nRed, "%s", dt)
}
logs.Debug(buf.String())
}
示例4: logEndOfRequest
func logEndOfRequest(ctx context.Context, duration time.Duration, mw mutil.WriterProxy) {
fields := logrus.Fields{
"status": mw.Status(),
"bytes": mw.BytesWritten(),
"duration": duration,
}
log.WithFields(ctx, fields).Info("Finished request")
}