(ctx context.Context, appName string, stream bool, n int, filter string)
| 16 | } |
| 17 | |
| 18 | func Logs(ctx context.Context, appName string, stream bool, n int, filter string) error { |
| 19 | c, err := config.ScalingoClient(ctx) |
| 20 | if err != nil { |
| 21 | return errors.Wrapf(ctx, err, "fail to get Scalingo client") |
| 22 | } |
| 23 | |
| 24 | err = checkFilter(ctx, c, appName, filter) |
| 25 | if err != nil { |
| 26 | return errors.Wrap(ctx, err, "check logs filter") |
| 27 | } |
| 28 | |
| 29 | logsURLRes, err := c.LogsURL(ctx, appName) |
| 30 | if err != nil { |
| 31 | return errors.Wrapf(ctx, err, "fetch logs URL for app %s", appName) |
| 32 | } |
| 33 | |
| 34 | err = logs.Dump(ctx, logsURLRes.LogsURL, n, filter) |
| 35 | if err != nil { |
| 36 | return errors.Wrap(ctx, err, "dump application logs") |
| 37 | } |
| 38 | |
| 39 | if stream { |
| 40 | err := logs.Stream(ctx, logsURLRes.LogsURL, filter) |
| 41 | if err != nil { |
| 42 | return errors.Wrap(ctx, err, "stream application logs") |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | return nil |
| 47 | } |
| 48 | |
| 49 | func checkFilter(ctx context.Context, c *scalingo.Client, appName string, filter string) error { |
| 50 | if filter == "" { |
no test coverage detected