Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
more friendly yaml output
Browse files Browse the repository at this point in the history
Signed-off-by: Achille Roussel <[email protected]>
  • Loading branch information
achille-roussel committed Jun 1, 2023
1 parent 2ae1197 commit 8306a09
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/debug/nettrace/nettrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nettrace

import (
"encoding"
"encoding/base64"
"encoding/hex"
"fmt"
"time"
Expand All @@ -15,7 +16,7 @@ import (
type Bytes []byte

func (b Bytes) MarshalYAML() (any, error) {
return hex.EncodeToString(b), nil
return base64.StdEncoding.EncodeToString(b), nil
}

type Protocol uint8
Expand Down Expand Up @@ -147,7 +148,7 @@ type Event struct {
FD wasi.FD `json:"fd" yaml:"fd"`
Addr wasi.SocketAddress `json:"addr,omitempty" yaml:"addr,omitempty"`
Peer wasi.SocketAddress `json:"peer,omitempty" yaml:"peer,omitempty"`
Data []wasi.IOVec `json:"data,omitempty" yaml:"data,omitempty"`
Data []Bytes `json:"data,omitempty" yaml:"data,omitempty"`
}

func (e Event) Format(w fmt.State, _ rune) {
Expand Down Expand Up @@ -181,7 +182,7 @@ func (e Event) Format(w fmt.State, _ rune) {
}
}

func iovecSize(iovs []wasi.IOVec) (size wasi.Size) {
func iovecSize(iovs []Bytes) (size wasi.Size) {
for _, iov := range iovs {
size += wasi.Size(len(iov))
}
Expand Down Expand Up @@ -217,7 +218,7 @@ func (e *Event) write(iovs []wasi.IOVec, size wasi.Size) {
}
if iovLen != 0 {
size -= iovLen
e.Data = append(e.Data, iov)
e.Data = append(e.Data, Bytes(iov))
}
}
}
Expand Down

0 comments on commit 8306a09

Please sign in to comment.