forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 9
/
stdin.go
29 lines (22 loc) · 827 Bytes
/
stdin.go
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
package log
import (
"os"
)
// Stdin reads all incoming traffic from stdin and sends it directly to the output
func (h *Harvester) openStdin() error {
h.source = Pipe{File: os.Stdin}
var err error
h.encoding, err = h.encodingFactory(h.source)
return err
}
// restrict file to minimal interface of FileSource to prevent possible casts
// to additional interfaces supported by underlying file
type Pipe struct {
File *os.File
}
func (p Pipe) Read(b []byte) (int, error) { return p.File.Read(b) }
func (p Pipe) Close() error { return p.File.Close() }
func (p Pipe) Name() string { return p.File.Name() }
func (p Pipe) Stat() (os.FileInfo, error) { return p.File.Stat() }
func (p Pipe) Continuable() bool { return false }
func (p Pipe) HasState() bool { return false }