mirror of
https://github.com/alibaba/higress.git
synced 2026-04-29 16:07:28 +08:00
add plugin start log in sdk (#1831)
This commit is contained in:
@@ -44,10 +44,12 @@ type Log interface {
|
||||
Errorf(format string, args ...interface{})
|
||||
Critical(msg string)
|
||||
Criticalf(format string, args ...interface{})
|
||||
resetID(pluginID string)
|
||||
}
|
||||
|
||||
type DefaultLog struct {
|
||||
pluginName string
|
||||
pluginID string
|
||||
}
|
||||
|
||||
func (l *DefaultLog) log(level LogLevel, msg string) {
|
||||
@@ -56,7 +58,7 @@ func (l *DefaultLog) log(level LogLevel, msg string) {
|
||||
if requestID == "" {
|
||||
requestID = "nil"
|
||||
}
|
||||
msg = fmt.Sprintf("[%s] [%s] %s", l.pluginName, requestID, msg)
|
||||
msg = fmt.Sprintf("[%s] [%s] [%s] %s", l.pluginName, l.pluginID, requestID, msg)
|
||||
switch level {
|
||||
case LogLevelTrace:
|
||||
proxywasm.LogTrace(msg)
|
||||
@@ -79,7 +81,7 @@ func (l *DefaultLog) logFormat(level LogLevel, format string, args ...interface{
|
||||
if requestID == "" {
|
||||
requestID = "nil"
|
||||
}
|
||||
format = fmt.Sprintf("[%s] [%s] %s", l.pluginName, requestID, format)
|
||||
format = fmt.Sprintf("[%s] [%s] [%s] %s", l.pluginName, l.pluginID, requestID, format)
|
||||
switch level {
|
||||
case LogLevelTrace:
|
||||
proxywasm.LogTracef(format, args...)
|
||||
@@ -143,3 +145,7 @@ func (l *DefaultLog) Critical(msg string) {
|
||||
func (l *DefaultLog) Criticalf(format string, args ...interface{}) {
|
||||
l.logFormat(LogLevelCritical, format, args...)
|
||||
}
|
||||
|
||||
func (l *DefaultLog) resetID(pluginID string) {
|
||||
l.pluginID = pluginID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user