This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new ae413d2b [operator] Supplemental Partial Log Library Logic v3
ae413d2b is described below
commit ae413d2bcdfc97fc7d57c50f9193bf68f5ef6676
Author: mfordjody <[email protected]>
AuthorDate: Sat Dec 14 09:50:09 2024 +0800
[operator] Supplemental Partial Log Library Logic v3
---
operator/pkg/util/clog/log/config.go | 16 ++++++++++++++++
operator/pkg/util/clog/log/default.go | 4 ++--
operator/pkg/util/clog/log/scope.go | 26 ++++++++++++++++++++++++--
3 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/operator/pkg/util/clog/log/config.go
b/operator/pkg/util/clog/log/config.go
new file mode 100644
index 00000000..54e996b6
--- /dev/null
+++ b/operator/pkg/util/clog/log/config.go
@@ -0,0 +1,16 @@
+package log
+
+import (
+ "go.uber.org/atomic"
+ "go.uber.org/zap/zapcore"
+)
+
+var (
+ funcs = &atomic.Value{}
+ useJSON atomic.Value
+)
+
+type patchTable struct {
+ write func(ent zapcore.Entry, fields []zapcore.Field) error
+ errorSink zapcore.WriteSyncer
+}
diff --git a/operator/pkg/util/clog/log/default.go
b/operator/pkg/util/clog/log/default.go
index 63243f8f..717034c9 100644
--- a/operator/pkg/util/clog/log/default.go
+++ b/operator/pkg/util/clog/log/default.go
@@ -1,7 +1,7 @@
package log
-var defaultScope = registerDefaultScopes()
-
func registerDefaultScopes() (defaults *Scope) {
return registerScope(DefaultScopeName, "Unscoped logging messages.", 1)
}
+
+var defaultScope = registerDefaultScopes()
diff --git a/operator/pkg/util/clog/log/scope.go
b/operator/pkg/util/clog/log/scope.go
index efb27e7b..a42c8562 100644
--- a/operator/pkg/util/clog/log/scope.go
+++ b/operator/pkg/util/clog/log/scope.go
@@ -17,6 +17,9 @@ type Scope struct {
outputLevel *atomic.Value
stackTraceLevel *atomic.Value
logCallers *atomic.Value
+ labels map[string]any
+ labelKeys []string
+ callerSkip int
}
var (
@@ -25,10 +28,10 @@ var (
)
func RegisterScope(name string, desc string) *Scope {
- return registerScope(name, desc)
+ return registerScope(name, desc, 0)
}
-func registerScope(name string, desc string) *Scope {
+func registerScope(name string, desc string, callerSkip int) *Scope {
if strings.ContainsAny(name, ":,.") {
panic(fmt.Sprintf("scope name %s is invalid, it cannot contain
colons, commas, or periods", name))
}
@@ -38,14 +41,33 @@ func registerScope(name string, desc string) *Scope {
if !ok {
s = &Scope{
name: name,
+ callerSkip: callerSkip,
outputLevel: &atomic.Value{},
stackTraceLevel: &atomic.Value{},
logCallers: &atomic.Value{},
}
+ s.SetOutputLevel(InfoLevel)
+ s.SetStackTraceLevel(NoneLevel)
+ s.SetLogCallers(false)
+ if name != DefaultScopeName {
+ s.nameToEmit = name
+ }
+ scopes[name] = s
}
+ s.labels = make(map[string]any)
return s
}
+func (s *Scope) SetOutputLevel(l Level) {
+ s.outputLevel.Store(l)
+}
+func (s *Scope) SetStackTraceLevel(l Level) {
+ s.stackTraceLevel.Store(l)
+}
+func (s *Scope) SetLogCallers(logCallers bool) {
+ s.logCallers.Store(logCallers)
+}
+
func (s *Scope) GetOutputLevel() Level {
return s.outputLevel.Load().(Level)
}