Move creating and opening file to json transport constructor

This commit is contained in:
Matija Petrunic
2021-09-16 15:22:18 +02:00
parent 515925a178
commit d067bc9f01
2 changed files with 9 additions and 5 deletions
+7 -2
View File
@@ -10,10 +10,15 @@ type jsonTracerTransport struct {
out *os.File
}
func NewJsonTracerTransport(out *os.File) TracerTransport {
func NewJsonTracerTransport(file string) (TracerTransport, error) {
out, err := os.OpenFile(file, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0660)
if err != nil {
return nil, err
}
return &jsonTracerTransport{
out: out,
}
}, nil
}
func (jtt *jsonTracerTransport) Transport(evt TracerTransportEvent) error {