MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / getUserLogPath

Function getUserLogPath

pkg/controller/rtctrl/logstore.go:100–137  ·  view source on GitHub ↗
(requestID, runtimeID, userID, funcName, funcVer, fpath, logtype string)

Source from the content-addressed store, hash-verified

98)
99
100func getUserLogPath(requestID, runtimeID, userID, funcName, funcVer, fpath, logtype string) string {
101 var logpath string
102
103 if logtype != string(UserLogTypePlain) {
104 if _, err := os.Stat(fpath); err != nil {
105 return ""
106 }
107 logpath = path.Join(fpath, userLogSingleFile)
108 return logpath
109 }
110
111 logpath = path.Join(fpath, fmt.Sprintf("%s.%s.%s", userID, funcName, strings.TrimLeft(funcVer, "$")))
112 _, err := os.Stat(logpath)
113 if err != nil {
114 if os.IsNotExist(err) {
115 err = os.MkdirAll(logpath, 0755)
116 if err != nil {
117 logs.V(4).Warn(fmt.Sprintf("recvlog %s create dir %s failed: %s",
118 runtimeID, logpath, err.Error()), zap.String("request_id", requestID))
119 logpath = ""
120 }
121 } else {
122 logs.V(4).Warn(fmt.Sprintf("recvlog %s stat dir %s failed: %s",
123 runtimeID, logpath, err.Error()), zap.String("request_id", requestID))
124 logpath = ""
125 }
126 }
127 if len(logpath) > 0 {
128 logpath = path.Join(logpath, fmt.Sprintf("%d.%s", time.Now().UnixNano(), requestID))
129 _, err = os.Stat(logpath)
130 if err == nil {
131 logs.V(4).Warn(fmt.Sprintf("recvlog %s logfile %s already exist",
132 runtimeID, logpath), zap.String("request_id", requestID))
133 logpath = ""
134 }
135 }
136 return logpath
137}
138
139type LogStatStoreParameter struct {
140 RequestID string

Callers 1

newLogStatStoreFunction · 0.85

Calls 4

VFunction · 0.92
WarnMethod · 0.80
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected