1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-26 13:48:53 +08:00
Dejan Mijic 86f563ee10
Ensure codestyle adherence
Simplified code where possible. Fixed golint suggestions regarding the
missing godoc comments and unnecessary initialized variables.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-06 23:03:24 +02:00

33 lines
642 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) Publish(msg writer.RawMessage) error {
defer func(begin time.Time) {
ls.logger.Log(
"method", "publish",
"took", time.Since(begin),
)
}(time.Now())
return ls.Service.Publish(msg)
}