Skip to content

Commit a0ca4c5

Browse files
committed
Use 'nil' instead of empty map in 'catcher' calls system. Improve code readability and reduce memory allocation overhead.
1 parent fc19301 commit a0ca4c5

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

aws/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import (
1616
)
1717

1818
func main() {
19-
catcher.Info("Starting aws module...", map[string]any{})
19+
catcher.Info("Starting aws module...", nil)
2020
intKey := configuration.GetInternalKey()
2121
panelServ := configuration.GetPanelServiceName()
2222
if intKey == "" || panelServ == "" {
23-
catcher.Error("Internal key or panel service name is not set. Exiting...", nil, map[string]any{})
23+
catcher.Error("Internal key or panel service name is not set. Exiting...", nil, nil)
2424
os.Exit(1)
2525
}
2626
client := utmconf.NewUTMClient(intKey, "http://"+panelServ)
@@ -33,7 +33,7 @@ func main() {
3333

3434
for range ticker.C {
3535
if err := utils.ConnectionChecker(configuration.URL_CHECK_CONNECTION); err != nil {
36-
catcher.Error("Failed to establish connection", err, map[string]any{})
36+
catcher.Error("Failed to establish connection", err, nil)
3737
}
3838

3939
endTime := time.Now().UTC()
@@ -43,10 +43,10 @@ func main() {
4343
moduleConfig, err := client.GetUTMConfig(enum.AWS_IAM_USER)
4444
if err != nil {
4545
if strings.Contains(err.Error(), "invalid character '<'") {
46-
catcher.Error("error getting configuration of the AWS module: backend is not available", err, map[string]any{})
46+
catcher.Error("error getting configuration of the AWS module: backend is not available", err, nil)
4747
}
4848
if strings.TrimSpace(err.Error()) != "" {
49-
catcher.Error("error getting configuration of the AWS module", err, map[string]any{})
49+
catcher.Error("error getting configuration of the AWS module", err, nil)
5050
}
5151
continue
5252
}

aws/processor/processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (p *AWSProcessor) GetLogs(startTime, endTime time.Time, group types.ModuleG
140140
return !lastPage
141141
})
142142
if err != nil {
143-
return nil, catcher.Error("error getting log pages", err, map[string]any{})
143+
return nil, catcher.Error("error getting log pages", err, nil)
144144
}
145145
}
146146
}

aws/processor/sendData.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ func SendToLogstash(data []TransformedLog) error {
2828
for _, str := range data {
2929
body, err := json.Marshal(str)
3030
if err != nil {
31-
catcher.Error("error encoding log to JSON", err, map[string]any{})
31+
catcher.Error("error encoding log to JSON", err, nil)
3232
continue
3333
}
3434
if err := sendLogs(body); err != nil {
35-
catcher.Error("error sending logs to logstach", err, map[string]any{})
35+
catcher.Error("error sending logs to logstach", err, nil)
3636
continue
3737
}
3838
}
@@ -44,12 +44,12 @@ func sendLogs(log []byte) error {
4444

4545
req, err := http.NewRequest("POST", url, bytes.NewBuffer(log))
4646
if err != nil {
47-
return catcher.Error("error creating request", err, map[string]any{})
47+
return catcher.Error("error creating request", err, nil)
4848
}
4949

5050
resp, err := client.Do(req)
5151
if err != nil {
52-
return catcher.Error("error sending logs", err, map[string]any{})
52+
return catcher.Error("error sending logs", err, nil)
5353
}
5454
defer resp.Body.Close()
5555

0 commit comments

Comments
 (0)