Skip to content

Commit 9af3754

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

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

office365/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 O365 module", map[string]any{})
19+
catcher.Info("Starting O365 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.LoginUrl); err != nil {
36-
catcher.Error("External connection failure detected", err, map[string]any{})
36+
catcher.Error("External connection failure detected", err, nil)
3737
}
3838

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

office365/processor/processor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,23 @@ func (o *OfficeProcessor) GetLogs(startTime time.Time, endTime time.Time, group
137137
for _, subscription := range o.Subscriptions {
138138
contentList, err := o.GetContentList(subscription, startTime, endTime, group)
139139
if err != nil {
140-
catcher.Error("error getting content list", err, map[string]any{})
140+
catcher.Error("error getting content list", err, nil)
141141
continue
142142
}
143143
logsCounter := 0
144144
if len(contentList) > 0 {
145145
for _, log := range contentList {
146146
details, err := o.GetContentDetails(log.ContentUri)
147147
if err != nil {
148-
catcher.Error("error getting content details", err, map[string]any{})
148+
catcher.Error("error getting content details", err, nil)
149149
continue
150150
}
151151
if len(details) > 0 {
152152
logsCounter += len(details)
153153
cleanLogs := ETLProcess(details, group)
154154
err := SendToLogstash(cleanLogs)
155155
if err != nil {
156-
catcher.Error("error sending logs to logstash", err, map[string]any{})
156+
catcher.Error("error sending logs to logstash", err, nil)
157157
continue
158158
}
159159
}

office365/processor/pull.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ func PullLogs(startTime time.Time, endTime time.Time, group types.ModuleGroup) {
1414

1515
err := agent.GetAuth()
1616
if err != nil {
17-
catcher.Error("error getting auth token", err, map[string]any{})
17+
catcher.Error("error getting auth token", err, nil)
1818
return
1919
}
2020

2121
err = agent.StartSubscriptions()
2222
if err != nil {
23-
catcher.Error("error starting subscriptions", err, map[string]any{})
23+
catcher.Error("error starting subscriptions", err, nil)
2424
return
2525
}
2626

office365/processor/sendData.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ func SendToLogstash(data []TransformedLog) *logger.Error {
2929
for _, str := range data {
3030
body, err := json.Marshal(str)
3131
if err != nil {
32-
catcher.Error("error encoding log to JSON", err, map[string]any{})
32+
catcher.Error("error encoding log to JSON", err, nil)
3333
continue
3434
}
3535
if err := sendLogs(body); err != nil {
36-
catcher.Error("error sending logs to logstach", err, map[string]any{})
36+
catcher.Error("error sending logs to logstach", err, nil)
3737
continue
3838
}
3939
}
@@ -45,12 +45,12 @@ func sendLogs(log []byte) error {
4545

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

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

0 commit comments

Comments
 (0)