Skip to content

Commit

Permalink
(fix) slog message
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Aug 10, 2024
1 parent 9365c1b commit f586ab9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ func sendHealthCheck() {
Message: filePath,
})
}
slog.Info("Sending Health Check Notify", "details", details)

var logDetails []interface{}
for _, detail := range details {
logDetails = append(logDetails, detail.Label, detail.Message)
}
slog.Info("Sending Health Check Notify", logDetails...)
if f.MSTeamsHook == "" {
return
}
Expand Down Expand Up @@ -184,7 +189,12 @@ func watch(filePath string) {
func notify(result *pkg.ScanResult) {
slog.Info("Sending to MS Teams")
details := pkg.GetAlertDetails(&f, result)
slog.Info("Sending Alert Notify", "details", details)

var logDetails []interface{}
for _, detail := range details {
logDetails = append(logDetails, detail.Label, detail.Message)
}
slog.Info("Sending Alert Notify", logDetails...)

if f.MSTeamsHook == "" {
return
Expand Down
11 changes: 8 additions & 3 deletions pkg/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func PrintMemUsage(f *Flags) {
"HeapSys (Bytes)", m.HeapSys,
)
if f.MemLimit > 0 && m.Alloc > uint64(f.MemLimit*1024*1024) {
SendHealthCheck(f, &m)
sendPanicCheck(f, &m)
panic("Memory Limit Exceeded")
}
}
Expand All @@ -48,9 +48,14 @@ func ExecShell(command string) (string, error) {
return string(out), err
}

func SendHealthCheck(f *Flags, m *runtime.MemStats) {
func sendPanicCheck(f *Flags, m *runtime.MemStats) {
details := GetPanicDetails(f, m)
slog.Warn("Sending Panic Notify", "details", details)
var logDetails []interface{}
for _, detail := range details {
logDetails = append(logDetails, detail.Label, detail.Message)
}
slog.Warn("Sending Panic Check", logDetails...)

if f.MSTeamsHook == "" {
return
}
Expand Down

0 comments on commit f586ab9

Please sign in to comment.