Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
loki/pkg/logcli/output/raw.go

38 lines
811 B

package output
import (
"fmt"
"io"
"time"
"github.com/grafana/loki/pkg/loghttp"
)
// RawOutput prints logs in their original form, without any metadata
type RawOutput struct {
w io.Writer
options *LogOutputOptions
}
func NewRaw(writer io.Writer, options *LogOutputOptions) LogOutput {
return &RawOutput{
w: writer,
options: options,
}
}
// Format a log entry as is
func (o *RawOutput) FormatAndPrintln(ts time.Time, lbls loghttp.LabelSet, maxLabelsLen int, line string) {
if len(line) > 0 && line[len(line)-1] == '\n' {
line = line[:len(line)-1]
}
fmt.Fprintln(o.w, line)
}
// WithWriter returns a copy of the LogOutput with the writer set to the given writer
func (o RawOutput) WithWriter(w io.Writer) LogOutput {
return &RawOutput{
w: w,
options: o.options,
}
}