2019-01-20 20:10:40 +00:00
|
|
|
package telemetry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Store records usage data.
|
|
|
|
type Store interface {
|
|
|
|
// WriteMessage stores data into the store.
|
|
|
|
WriteMessage(ctx context.Context, data []byte) error
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Store = (*LogStore)(nil)
|
|
|
|
|
|
|
|
// LogStore logs data written to the store.
|
|
|
|
type LogStore struct {
|
2019-12-04 23:10:23 +00:00
|
|
|
log *zap.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLogStore(log *zap.Logger) *LogStore {
|
|
|
|
return &LogStore{
|
|
|
|
log: log,
|
|
|
|
}
|
2019-01-20 20:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WriteMessage logs data at Info level.
|
|
|
|
func (s *LogStore) WriteMessage(ctx context.Context, data []byte) error {
|
2019-12-04 23:10:23 +00:00
|
|
|
s.log.Info("Write", zap.String("data", string(data)))
|
2019-01-20 20:10:40 +00:00
|
|
|
return nil
|
|
|
|
}
|