@@ -232,7 +232,7 @@ func (ctx *Context) NotFound(logMsg string, logErr error) {
232
232
233
233
func (ctx * Context ) notFoundInternal (logMsg string , logErr error ) {
234
234
if logErr != nil {
235
- log .ErrorWithSkip ( 2 , "%s: %v" , logMsg , logErr )
235
+ log .Log ( 2 , log . DEBUG , "%s: %v" , logMsg , logErr )
236
236
if ! setting .IsProd {
237
237
ctx .Data ["ErrorMsg" ] = logErr
238
238
}
@@ -248,7 +248,7 @@ func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
248
248
}
249
249
250
250
if ! showHTML {
251
- ctx .PlainText (http .StatusNotFound , "Not found.\n " )
251
+ ctx .PlainText (http .StatusNotFound , "Not found.\n " , 2 )
252
252
return
253
253
}
254
254
@@ -286,21 +286,29 @@ func (ctx *Context) NotFoundOrServerError(logMsg string, errCheck func(error) bo
286
286
}
287
287
288
288
// PlainTextBytes renders bytes as plain text
289
- func (ctx * Context ) PlainTextBytes (status int , bs []byte ) {
290
- if (status / 100 == 4 ) || (status / 100 == 5 ) {
291
- log .Error ("PlainTextBytes: %s" , string (bs ))
289
+ func (ctx * Context ) PlainTextBytes (status int , bs []byte , optionalSkip ... int ) {
290
+ skip := 1
291
+ if len (optionalSkip ) == 1 {
292
+ skip = optionalSkip [0 ] + 1
293
+ }
294
+ if status / 100 == 4 || status / 100 == 5 {
295
+ log .Log (skip , log .TRACE , "PlainTextBytes: %s" , string (bs ))
292
296
}
293
297
ctx .Resp .WriteHeader (status )
294
298
ctx .Resp .Header ().Set ("Content-Type" , "text/plain;charset=utf-8" )
295
299
ctx .Resp .Header ().Set ("X-Content-Type-Options" , "nosniff" )
296
300
if _ , err := ctx .Resp .Write (bs ); err != nil {
297
- log .Error ( "Write bytes failed: %v" , err )
301
+ log .ErrorWithSkip ( skip , "Write bytes failed: %v" , err )
298
302
}
299
303
}
300
304
301
305
// PlainText renders content as plain text
302
- func (ctx * Context ) PlainText (status int , text string ) {
303
- ctx .PlainTextBytes (status , []byte (text ))
306
+ func (ctx * Context ) PlainText (status int , text string , optionalSkip ... int ) {
307
+ skip := 1
308
+ if len (optionalSkip ) == 1 {
309
+ skip = optionalSkip [0 ] + 1
310
+ }
311
+ ctx .PlainTextBytes (status , []byte (text ), skip )
304
312
}
305
313
306
314
// RespHeader returns the response header
0 commit comments