func ExampleParseLogLine() {
	line := "Mon Feb 23 03:20:19.670 [TTLMonitor] query local.system.indexes query: { expireAfterSeconds: { $exists: true } } ntoreturn:0 ntoskip:0 nscanned:0 keyUpdates:0 locks(micros) r:86 nreturned:0 reslen:20 0ms"
	doc, _ := parser.ParseLogLine(line)
	buf, _ := json.Marshal(doc)
	fmt.Print(string(buf))
	// output:
	// {"context":"TTLMonitor","duration_ms":"0","keyUpdates":0,"nreturned":0,"ns":"local.system.indexes","nscanned":0,"ntoreturn":0,"ntoskip":0,"op":"query","query":{"expireAfterSeconds":{"$exists":true}},"r":86,"reslen":20,"timestamp":"Mon Feb 23 03:20:19.670"}
}
Exemple #2
0
func ingest(r io.Reader, w io.Writer) error {
	s := bufio.NewScanner(r)
	out := json.NewEncoder(w)
	for s.Scan() {
		r, err := parser.ParseLogLine(s.Text())
		if err != nil {
			return err
		}
		out.Encode(r)
	}
	return nil
}