cmd/tailscale/cli: fix time parsing in debug daemon-logs (#19875)
Fixes #19874 Signed-off-by: Erisa A <erisa@tailscale.com>
This commit is contained in:
@@ -786,10 +786,13 @@ func runDaemonLogs(ctx context.Context, args []string) error {
|
|||||||
}
|
}
|
||||||
d := json.NewDecoder(logs)
|
d := json.NewDecoder(logs)
|
||||||
for {
|
for {
|
||||||
|
type logtail struct {
|
||||||
|
Time string `json:"client_time"`
|
||||||
|
}
|
||||||
var line struct {
|
var line struct {
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
Verbose int `json:"v"`
|
Verbose int `json:"v"`
|
||||||
Time string `json:"client_time"`
|
Logtail logtail `json:"logtail"`
|
||||||
}
|
}
|
||||||
err := d.Decode(&line)
|
err := d.Decode(&line)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -799,8 +802,8 @@ func runDaemonLogs(ctx context.Context, args []string) error {
|
|||||||
if line.Text == "" || line.Verbose > daemonLogsArgs.verbose {
|
if line.Text == "" || line.Verbose > daemonLogsArgs.verbose {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if daemonLogsArgs.time {
|
if daemonLogsArgs.time && line.Logtail.Time != "" {
|
||||||
fmt.Printf("%s %s\n", line.Time, line.Text)
|
fmt.Printf("%s %s\n", line.Logtail.Time, line.Text)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(line.Text)
|
fmt.Println(line.Text)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user