Exemplo n.º 1
0
func line(w io.Writer, start string, key, v2 types.Value) {
	var err error
	pw := prefixWriter{w: w, prefix: []byte(start)}
	_, err = w.Write([]byte(start))
	d.Exp.NoError(err)
	if key != nil {
		d.Exp.NoError(types.WriteEncodedValue(pw, key))
		_, err = w.Write([]byte(": "))
		d.Exp.NoError(err)
	}
	d.Exp.NoError(types.WriteEncodedValue(pw, v2))
	_, err = w.Write([]byte("\n"))
	d.Exp.NoError(err)
}
Exemplo n.º 2
0
func writeEncodedValue(w io.Writer, v types.Value) error {
	if v.Type().Kind() != types.BlobKind {
		return types.WriteEncodedValue(w, v)
	}
	write(w, []byte("Blob ("))
	write(w, []byte(humanize.Bytes(v.(types.Blob).Len())))
	return write(w, []byte(")"))
}
Exemplo n.º 3
0
func writeEncodedValue(w io.Writer, v types.Value) {
	if v.Type().Kind() == types.BlobKind {
		w.Write([]byte("Blob ("))
		w.Write([]byte(humanize.Bytes(v.(types.Blob).Len())))
		w.Write([]byte(")"))
	} else {
		d.PanicIfError(types.WriteEncodedValue(w, v))
	}
}
Exemplo n.º 4
0
func writeMetaLines(node LogNode, maxLines, lineno, maxLabelLen int, w io.Writer) (int, error) {
	if m, ok := node.commit.MaybeGet(datas.MetaField); ok {
		meta := m.(types.Struct)
		mlw := &maxLineWriter{numLines: lineno, maxLines: maxLines, node: node, dest: w, needsPrefix: true, showGraph: showGraph}
		err := d.Try(func() {
			meta.Type().Desc.(types.StructDesc).IterFields(func(fieldName string, t *types.Type) {
				v := meta.Get(fieldName)
				fmt.Fprintf(mlw, "%-*s", maxLabelLen+2, strings.Title(fieldName)+":")
				types.WriteEncodedValue(mlw, v)
				fmt.Fprintf(mlw, "\n")
			})
		})
		return mlw.numLines, err
	}
	return lineno, nil
}