frostfs-http-gw/internal/net/event_handler.go
Aleksey Kravchenko eb5d1b40d6
All checks were successful
/ DCO (pull_request) Successful in 35s
/ Vulncheck (pull_request) Successful in 53s
/ Builds (pull_request) Successful in 1m6s
/ OCI image (pull_request) Successful in 1m26s
/ Lint (pull_request) Successful in 2m14s
/ Tests (pull_request) Successful in 1m9s
/ Integration tests (pull_request) Successful in 5m38s
[#195] Add tags support
Signed-off-by: Aleksey Kravchenko <al.kravchenko@yadro.com>
2025-02-05 10:51:44 +03:00

31 lines
794 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) {
log := l.logger.With(logs.TagField(logs.TagApp))
sourceIPString := "undefined"
if sourceIP != nil {
sourceIPString = sourceIP.Network() + "://" + sourceIP.String()
}
if err == nil {
log.Debug(logs.MultinetDialSuccess, zap.String("source", sourceIPString),
zap.String("destination", address))
} else {
log.Debug(logs.MultinetDialFail, zap.String("source", sourceIPString),
zap.String("destination", address))
}
}
func NewLogEventHandler(logger *zap.Logger) LogEventHandler {
return LogEventHandler{logger: logger}
}