frostfs-http-gw/internal/net/event_handler.go
Aleksey Kravchenko 6ca273e3ee
Some checks failed
/ DCO (pull_request) Successful in 38s
/ Builds (pull_request) Successful in 59s
/ Vulncheck (pull_request) Failing after 1m0s
/ OCI image (pull_request) Successful in 1m19s
/ Lint (pull_request) Successful in 3m26s
/ Tests (pull_request) Successful in 1m6s
/ Integration tests (pull_request) Successful in 5m33s
[#195] Add tags support
Signed-off-by: Aleksey Kravchenko <al.kravchenko@yadro.com>
2025-02-07 09:05:41 +03:00

30 lines
810 B
Go

package net
import (
"net"
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/logs"
"go.uber.org/zap"
)
type LogEventHandler struct {
logger *zap.Logger
}
func (l LogEventHandler) DialPerformed(sourceIP net.Addr, _, address string, err error) {
sourceIPString := "undefined"
if sourceIP != nil {
sourceIPString = sourceIP.Network() + "://" + sourceIP.String()
}
if err == nil {
l.logger.Debug(logs.MultinetDialSuccess, zap.String("source", sourceIPString),
zap.String("destination", address), logs.TagField(logs.TagApp))
} else {
l.logger.Debug(logs.MultinetDialFail, zap.String("source", sourceIPString),
zap.String("destination", address), logs.TagField(logs.TagApp))
}
}
func NewLogEventHandler(logger *zap.Logger) LogEventHandler {
return LogEventHandler{logger: logger}
}