-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathposter.go
More file actions
49 lines (39 loc) · 935 Bytes
/
poster.go
File metadata and controls
49 lines (39 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package json
import (
"context"
"encoding/json"
"io"
"github.com/src-d/lookout"
"gopkg.in/src-d/go-log.v1"
)
// Poster prints json comments to stdout
type Poster struct {
writer io.Writer
enc *json.Encoder
}
var _ lookout.Poster = &Poster{}
// NewPoster creates a new json poster for stdout
func NewPoster(w io.Writer) *Poster {
return &Poster{
writer: w,
enc: json.NewEncoder(w),
}
}
// Post prints json comments to sdtout
func (p *Poster) Post(ctx context.Context, e lookout.Event,
aCommentsList []lookout.AnalyzerComments) error {
for _, a := range aCommentsList {
for _, c := range a.Comments {
if err := p.enc.Encode(c); err != nil {
return err
}
}
}
return nil
}
// Status prints the new status to the log
func (p *Poster) Status(ctx context.Context, e lookout.Event,
status lookout.AnalysisStatus) error {
log.With(log.Fields{"status": status}).Infof("New status")
return nil
}