frostfs-http-gw/internal/net/event_handler.go
Aleksey Kravchenko ec629ffb65
All checks were successful
/ DCO (pull_request) Successful in 47s
/ Vulncheck (pull_request) Successful in 49s
/ Builds (pull_request) Successful in 1m2s
/ OCI image (pull_request) Successful in 1m14s
/ Lint (pull_request) Successful in 2m8s
/ Tests (pull_request) Successful in 57s
/ Integration tests (pull_request) Successful in 5m32s
[#195] Add tags support
Signed-off-by: Aleksey Kravchenko <al.kravchenko@yadro.com>
2025-02-05 10:58:23 +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}
}