MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / Error

Method Error

cli/pkg/common/log.go:147–197  ·  view source on GitHub ↗
(err interface{}, headers ...string)

Source from the content-addressed store, hash-verified

145}
146
147func (sLog *smartIDELogStruct) Error(err interface{}, headers ...string) (reErr error) {
148
149 if err == nil {
150 return nil
151 }
152
153 // 基本的信息
154 contents := headers
155 contents = append(contents, fmt.Sprint(err))
156
157 // 前缀
158 prefix := getPrefix(zapcore.ErrorLevel)
159 contents = RemoveDuplicatesAndEmpty(contents)
160
161 // 堆栈
162 stack := string(debug.Stack())
163 fullContents := append(contents, stack)
164 fullContents = RemoveDuplicatesAndEmpty(fullContents)
165 if sLog.Ws_id != "" {
166 ch <- struct{}{}
167 WG.Add(1)
168 go func() {
169 SendAndReceive("business", "workspaceLog", "", "", model.WorkspaceLog{
170 Title: "",
171 ParentId: sLog.ParentId,
172 Content: strings.Join(fullContents, ";"),
173 Ws_id: sLog.Ws_id,
174 Level: 4,
175 Type: 1,
176 StartAt: time.Now(),
177 EndAt: time.Now(),
178 })
179 defer WG.Done()
180 <-ch
181 }()
182 }
183 fullContents = entryptionKeys(fullContents) // 加密密钥
184
185 // 调试模式时向控制台输出堆栈
186 if isDebugLevel {
187 fmt.Println(prefix, strings.Join(fullContents, "; "))
188 } else {
189 fmt.Println(prefix, strings.Join(contents, "; "))
190 }
191
192 // 日志中一定输出完整的日志
193 sugarLogger.Error(fullContents)
194 os.Exit(1)
195
196 return nil
197}
198
199func (sLog *smartIDELogStruct) Fatal(fatal interface{}, headers ...string) {
200 if fatal != nil {

Callers 15

newK8sUtilFunction · 0.45
GitCloneMethod · 0.45
StartAgentMethod · 0.45
TestValidateFunction · 0.45
TestIOErrorFunction · 0.45
raiseErrorMethod · 0.45
encryptFunction · 0.45
decryptFunction · 0.45
RetryFunction · 0.45
IsPortAvailableMethod · 0.45
CheckRemoteEnvMethod · 0.45
GitCloneMethod · 0.45

Calls 5

getPrefixFunction · 0.85
RemoveDuplicatesAndEmptyFunction · 0.85
SendAndReceiveFunction · 0.85
entryptionKeysFunction · 0.85
JoinMethod · 0.45

Tested by 2

TestValidateFunction · 0.36
TestIOErrorFunction · 0.36