func newLogStatStore(requestID, runtimeID, userID, funcName, funcVer, fpath, logtype string) LogStatStore {
(params *LogStatStoreParameter)
| 150 | |
| 151 | //func newLogStatStore(requestID, runtimeID, userID, funcName, funcVer, fpath, logtype string) LogStatStore { |
| 152 | func 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 | |
| 184 | func (s *kunLogStatStore) Receiver() string { |
| 185 | return s.runtimeID |