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

Function newLogStatStore

pkg/controller/rtctrl/logstore.go:152–182  ·  view source on GitHub ↗

func newLogStatStore(requestID, runtimeID, userID, funcName, funcVer, fpath, logtype string) LogStatStore {

(params *LogStatStoreParameter)

Source from the content-addressed store, hash-verified

150
151//func newLogStatStore(requestID, runtimeID, userID, funcName, funcVer, fpath, logtype string) LogStatStore {
152func newLogStatStore(params *LogStatStoreParameter) LogStatStore {
153 logpath := getUserLogPath(params.RequestID, params.RuntimeID, params.UserID, params.FunctionName, params.FunctionVersion, params.FilePath, params.LogType)
154 logfile, err := userlog.CreateLogWriter(params.LogType, logpath, maxUserLogSize)
155 if err != nil {
156 logpath = ""
157 if params.LogType == "" || params.LogType == "none" {
158 logs.Info(fmt.Sprintf("create logfile failed: %v", err),
159 zap.String("request_id", params.RequestID))
160 } else {
161 logs.V(4).Warn(fmt.Sprintf("create logfile failed: %v", err),
162 zap.String("request_id", params.RequestID))
163 }
164 }
165 buf := logBufPool.Get().(*bytes.Buffer)
166 buf.Reset()
167 r := &kunLogStatStore{
168 requestID: params.RequestID,
169 runtimeID: params.RuntimeID,
170 triggerType: params.TriggerType,
171 userID: params.UserID,
172 funcName: params.FunctionName,
173 funcBrn: params.FunctionBrn,
174 funcVersion: params.FunctionVersion,
175 fpath: logpath,
176 remain: defaultUserLogLength,
177 logbuf: buf,
178 logfile: logfile,
179 }
180 r.waitg.Add(2)
181 return r
182}
183
184func (s *kunLogStatStore) Receiver() string {
185 return s.runtimeID

Callers 4

TestKunLogStatStoreFunction · 0.85
TestStdlogHandlerFunction · 0.85
TestStatisticHandlerFunction · 0.85
startRecvLogMethod · 0.85

Calls 9

CreateLogWriterFunction · 0.92
InfoFunction · 0.92
VFunction · 0.92
getUserLogPathFunction · 0.85
WarnMethod · 0.80
StringMethod · 0.65
GetMethod · 0.65
ResetMethod · 0.45
AddMethod · 0.45

Tested by 3

TestKunLogStatStoreFunction · 0.68
TestStdlogHandlerFunction · 0.68
TestStatisticHandlerFunction · 0.68