diff options
author | zeripath <art27@cantab.net> | 2023-02-13 03:17:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-13 11:17:36 +0800 |
commit | e4238583db1647e05d0d664e5b2adae80b6270dc (patch) | |
tree | 5b2eff60cb312cfe1955a79841091e1c9aa94e2e /modules/log/log.go | |
parent | 656d5a144fa4185b203e5e4d033e829449f9f6d1 (diff) | |
download | gitea-e4238583db1647e05d0d664e5b2adae80b6270dc.tar.gz gitea-e4238583db1647e05d0d664e5b2adae80b6270dc.zip |
Improve trace logging for pulls and processes (#22633) (#22812)
Backport #22633
Our trace logging is far from perfect and is difficult to follow.
This PR:
* Add trace logging for process manager add and remove.
* Fixes an errant read file for git refs in getMergeCommit
* Brings in the pullrequest `String` and `ColorFormat` methods
introduced in #22568
* Adds a lot more logging in to testPR etc.
Ref #22578
---------
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/log/log.go')
-rw-r--r-- | modules/log/log.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/log/log.go b/modules/log/log.go index 4303ecf4c0..e0a116e5e6 100644 --- a/modules/log/log.go +++ b/modules/log/log.go @@ -10,6 +10,8 @@ import ( "runtime" "strings" "sync" + + "code.gitea.io/gitea/modules/process" ) type loggerMap struct { @@ -286,6 +288,15 @@ func (l *LoggerAsWriter) Log(msg string) { } func init() { + process.Trace = func(start bool, pid process.IDType, description string, parentPID process.IDType, typ string) { + if start && parentPID != "" { + Log(1, TRACE, "Start %s: %s (from %s) (%s)", NewColoredValue(pid, FgHiYellow), description, NewColoredValue(parentPID, FgYellow), NewColoredValue(typ, Reset)) + } else if start { + Log(1, TRACE, "Start %s: %s (%s)", NewColoredValue(pid, FgHiYellow), description, NewColoredValue(typ, Reset)) + } else { + Log(1, TRACE, "Done %s: %s", NewColoredValue(pid, FgHiYellow), NewColoredValue(description, Reset)) + } + } _, filename, _, _ := runtime.Caller(0) prefix = strings.TrimSuffix(filename, "modules/log/log.go") if prefix == filename { |