mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 16:47:30 +00:00
Change some logging levels (#18421)
* Change some logging levels * PlainTextWithBytes - 4xx/5xx this should just be TRACE * notFoundInternal - the "error" here is too noisy and should be DEBUG * WorkerPool - Worker pool scaling messages are normal and should be DEBUG Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
e19b9653ea
commit
be77ede954
|
@ -232,7 +232,7 @@ func (ctx *Context) NotFound(logMsg string, logErr error) {
|
||||||
|
|
||||||
func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
|
func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
|
||||||
if logErr != nil {
|
if logErr != nil {
|
||||||
log.ErrorWithSkip(2, "%s: %v", logMsg, logErr)
|
log.Log(2, log.DEBUG, "%s: %v", logMsg, logErr)
|
||||||
if !setting.IsProd {
|
if !setting.IsProd {
|
||||||
ctx.Data["ErrorMsg"] = logErr
|
ctx.Data["ErrorMsg"] = logErr
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !showHTML {
|
if !showHTML {
|
||||||
ctx.PlainText(http.StatusNotFound, "Not found.\n")
|
ctx.plainTextInternal(3, http.StatusNotFound, []byte("Not found.\n"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,21 +286,27 @@ func (ctx *Context) NotFoundOrServerError(logMsg string, errCheck func(error) bo
|
||||||
}
|
}
|
||||||
|
|
||||||
// PlainTextBytes renders bytes as plain text
|
// PlainTextBytes renders bytes as plain text
|
||||||
func (ctx *Context) PlainTextBytes(status int, bs []byte) {
|
func (ctx *Context) plainTextInternal(skip, status int, bs []byte) {
|
||||||
if (status/100 == 4) || (status/100 == 5) {
|
statusPrefix := status / 100
|
||||||
log.Error("PlainTextBytes: %s", string(bs))
|
if statusPrefix == 4 || statusPrefix == 5 {
|
||||||
|
log.Log(skip, log.TRACE, "plainTextInternal (status=%d): %s", status, string(bs))
|
||||||
}
|
}
|
||||||
ctx.Resp.WriteHeader(status)
|
ctx.Resp.WriteHeader(status)
|
||||||
ctx.Resp.Header().Set("Content-Type", "text/plain;charset=utf-8")
|
ctx.Resp.Header().Set("Content-Type", "text/plain;charset=utf-8")
|
||||||
ctx.Resp.Header().Set("X-Content-Type-Options", "nosniff")
|
ctx.Resp.Header().Set("X-Content-Type-Options", "nosniff")
|
||||||
if _, err := ctx.Resp.Write(bs); err != nil {
|
if _, err := ctx.Resp.Write(bs); err != nil {
|
||||||
log.Error("Write bytes failed: %v", err)
|
log.ErrorWithSkip(skip, "plainTextInternal (status=%d): write bytes failed: %v", status, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PlainTextBytes renders bytes as plain text
|
||||||
|
func (ctx *Context) PlainTextBytes(status int, bs []byte) {
|
||||||
|
ctx.plainTextInternal(2, status, bs)
|
||||||
|
}
|
||||||
|
|
||||||
// PlainText renders content as plain text
|
// PlainText renders content as plain text
|
||||||
func (ctx *Context) PlainText(status int, text string) {
|
func (ctx *Context) PlainText(status int, text string) {
|
||||||
ctx.PlainTextBytes(status, []byte(text))
|
ctx.plainTextInternal(2, status, []byte(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RespHeader returns the response header
|
// RespHeader returns the response header
|
||||||
|
|
|
@ -118,7 +118,7 @@ func (p *WorkerPool) zeroBoost() {
|
||||||
boost = p.maxNumberOfWorkers - p.numberOfWorkers
|
boost = p.maxNumberOfWorkers - p.numberOfWorkers
|
||||||
}
|
}
|
||||||
if mq != nil {
|
if mq != nil {
|
||||||
log.Warn("WorkerPool: %d (for %s) has zero workers - adding %d temporary workers for %s", p.qid, mq.Name, boost, p.boostTimeout)
|
log.Debug("WorkerPool: %d (for %s) has zero workers - adding %d temporary workers for %s", p.qid, mq.Name, boost, p.boostTimeout)
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
pid := mq.RegisterWorkers(boost, start, true, start.Add(p.boostTimeout), cancel, false)
|
pid := mq.RegisterWorkers(boost, start, true, start.Add(p.boostTimeout), cancel, false)
|
||||||
|
@ -126,7 +126,7 @@ func (p *WorkerPool) zeroBoost() {
|
||||||
mq.RemoveWorkers(pid)
|
mq.RemoveWorkers(pid)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Warn("WorkerPool: %d has zero workers - adding %d temporary workers for %s", p.qid, p.boostWorkers, p.boostTimeout)
|
log.Debug("WorkerPool: %d has zero workers - adding %d temporary workers for %s", p.qid, p.boostWorkers, p.boostTimeout)
|
||||||
}
|
}
|
||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
p.addWorkers(ctx, cancel, boost)
|
p.addWorkers(ctx, cancel, boost)
|
||||||
|
@ -163,7 +163,7 @@ func (p *WorkerPool) pushBoost(data Data) {
|
||||||
boost = p.maxNumberOfWorkers - p.numberOfWorkers
|
boost = p.maxNumberOfWorkers - p.numberOfWorkers
|
||||||
}
|
}
|
||||||
if mq != nil {
|
if mq != nil {
|
||||||
log.Warn("WorkerPool: %d (for %s) Channel blocked for %v - adding %d temporary workers for %s, block timeout now %v", p.qid, mq.Name, ourTimeout, boost, p.boostTimeout, p.blockTimeout)
|
log.Debug("WorkerPool: %d (for %s) Channel blocked for %v - adding %d temporary workers for %s, block timeout now %v", p.qid, mq.Name, ourTimeout, boost, p.boostTimeout, p.blockTimeout)
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
pid := mq.RegisterWorkers(boost, start, true, start.Add(p.boostTimeout), boostCtxCancel, false)
|
pid := mq.RegisterWorkers(boost, start, true, start.Add(p.boostTimeout), boostCtxCancel, false)
|
||||||
|
@ -173,7 +173,7 @@ func (p *WorkerPool) pushBoost(data Data) {
|
||||||
boostCtxCancel()
|
boostCtxCancel()
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
log.Warn("WorkerPool: %d Channel blocked for %v - adding %d temporary workers for %s, block timeout now %v", p.qid, ourTimeout, p.boostWorkers, p.boostTimeout, p.blockTimeout)
|
log.Debug("WorkerPool: %d Channel blocked for %v - adding %d temporary workers for %s, block timeout now %v", p.qid, ourTimeout, p.boostWorkers, p.boostTimeout, p.blockTimeout)
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
<-time.After(p.boostTimeout)
|
<-time.After(p.boostTimeout)
|
||||||
|
|
Loading…
Reference in a new issue