Skip to content

[APP-7845] Change default log time filter to 1 day #4857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
5 changes: 3 additions & 2 deletions cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1909,8 +1909,9 @@ var app = &cli.App{
Usage: "filter logs by levels (e.g., info, warn, error)",
},
&cli.StringFlag{
Name: generalFlagStart,
Usage: "ISO-8601 timestamp in RFC3339 format indicating the start of the interval filter (e.g., 2025-01-15T14:00:00Z)",
Name: generalFlagStart,
Usage: "ISO-8601 timestamp in RFC3339 format indicating the start of the interval filter (e.g., 2025-01-15T14:00:00Z). " +
"Defaults to 12 hours ago if not specified",
},
&cli.StringFlag{
Name: generalFlagEnd,
Expand Down
7 changes: 7 additions & 0 deletions cli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const (
maxNumLogs = 10000
// logoMaxSize is the maximum size of a logo in bytes.
logoMaxSize = 1024 * 200 // 200 KB
// defaultLogStartTime is set to the last 12 hours
// because logs older than 12 hours are stored in the online archive.
defaultLogStartTime = -12 * time.Hour
// yellow is the format string used to output warnings in yellow color.
yellow = "\033[1;33m%s\033[0m"
)
Expand Down Expand Up @@ -869,6 +872,10 @@ func (c *viamClient) streamLogsForPart(part *apppb.RobotPart, args robotsLogsArg
return err
}

if args.Start == "" {
args.Start = time.Now().Add(defaultLogStartTime).UTC().Format(time.RFC3339)
}

startTime, err := parseTimeString(args.Start)
if err != nil {
return errors.Wrap(err, "invalid start time format")
Expand Down
Loading