github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/logcli/output/raw.go (about) 1 package output 2 3 import ( 4 "fmt" 5 "io" 6 "time" 7 8 "github.com/grafana/loki/pkg/loghttp" 9 ) 10 11 // RawOutput prints logs in their original form, without any metadata 12 type RawOutput struct { 13 w io.Writer 14 options *LogOutputOptions 15 } 16 17 func NewRaw(writer io.Writer, options *LogOutputOptions) LogOutput { 18 return &RawOutput{ 19 w: writer, 20 options: options, 21 } 22 } 23 24 // Format a log entry as is 25 func (o *RawOutput) FormatAndPrintln(ts time.Time, lbls loghttp.LabelSet, maxLabelsLen int, line string) { 26 if len(line) > 0 && line[len(line)-1] == '\n' { 27 line = line[:len(line)-1] 28 } 29 fmt.Fprintln(o.w, line) 30 }