You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not output "Trace" level logs from process manager by default (#24952)
The old process manager's `Trace` function by default calls `log.Printf`
to output "trace" level logs. That's not ideal because by default the
trace level logs should not be outputted. In history it didn't cause
problems because there was no other call to the process manager before
the logger system's initialization.
But if there is any package using the process manager before the "Trace"
function gets assigned to the logger system's trace function, the
process manager will outputs unexpected verbose messages, this behavior
is not expected in most cases.
Now, the logger system also uses process manager to manage its goroutine
contexts, so it's the time to fix the old "trace" behavior: by default,
do not output the trace level messages. Fix#24951
// the "process manager" also calls "log.Trace()" to output logs, so if we want to create new contexts by the manager, we need to disable the trace temporarily
Copy file name to clipboardExpand all lines: modules/process/manager.go
+25-8
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,10 @@ package process
6
6
7
7
import (
8
8
"context"
9
-
"log"
10
9
"runtime/pprof"
11
10
"strconv"
12
11
"sync"
12
+
"sync/atomic"
13
13
"time"
14
14
)
15
15
@@ -44,16 +44,33 @@ type IDType string
44
44
// - it is simply an alias for context.CancelFunc and is only for documentary purposes
45
45
typeFinishedFunc= context.CancelFunc
46
46
47
-
varTrace=defaultTrace// this global can be overridden by particular logging packages - thus avoiding import cycles
47
+
var (
48
+
traceDisabled atomic.Int64
49
+
TraceCallback=defaultTraceCallback// this global can be overridden by particular logging packages - thus avoiding import cycles
50
+
)
51
+
52
+
// defaultTraceCallback is a no-op. Without a proper TraceCallback (provided by the logger system), this "Trace" level messages shouldn't be outputted.
0 commit comments