mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-22 06:07:24 +08:00
filer.meta.tail: output json format for easier parsing
This commit is contained in:
@@ -3,9 +3,11 @@ package command
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/golang/protobuf/jsonpb"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/olivere/elastic/v7"
|
"github.com/olivere/elastic/v7"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -25,6 +27,10 @@ var cmdFilerMetaTail = &Command{
|
|||||||
Short: "see recent changes on a filer",
|
Short: "see recent changes on a filer",
|
||||||
Long: `See recent changes on a filer.
|
Long: `See recent changes on a filer.
|
||||||
|
|
||||||
|
weed filer.meta.tail -timeAgo=30h | grep truncate
|
||||||
|
weed filer.meta.tail -timeAgo=30h | jq .
|
||||||
|
weed filer.meta.tail -timeAgo=30h | jq .eventNotification.newEntry.name
|
||||||
|
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,8 +86,12 @@ func runFilerMetaTail(cmd *Command, args []string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsonpbMarshaler := jsonpb.Marshaler{
|
||||||
|
EmitDefaults: false,
|
||||||
|
}
|
||||||
eachEntryFunc := func(resp *filer_pb.SubscribeMetadataResponse) error {
|
eachEntryFunc := func(resp *filer_pb.SubscribeMetadataResponse) error {
|
||||||
fmt.Printf("dir:%s %+v\n", resp.Directory, resp.EventNotification)
|
jsonpbMarshaler.Marshal(os.Stdout, resp)
|
||||||
|
fmt.Fprintln(os.Stdout)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if *esServers != "" {
|
if *esServers != "" {
|
||||||
|
Reference in New Issue
Block a user