1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-26 13:48:53 +08:00
Drasko DRASKOVIC 199a44b0a0 Change writer message format - accept raw messages
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-29 16:18:41 +02:00

33 lines
620 B
Go

package api
import (
"time"
"github.com/go-kit/kit/log"
"github.com/mainflux/mainflux/http"
"github.com/mainflux/mainflux/writer"
)
var _ http.Service = (*loggingService)(nil)
type loggingService struct {
logger log.Logger
http.Service
}
// NewLoggingService adds logging facilities to the adapter.
func NewLoggingService(logger log.Logger, s http.Service) http.Service {
return &loggingService{logger, s}
}
func (ls *loggingService) Send(msg writer.RawMessage) {
defer func(begin time.Time) {
ls.logger.Log(
"method", "send",
"took", time.Since(begin),
)
}(time.Now())
ls.Service.Send(msg)
}