-
Notifications
You must be signed in to change notification settings - Fork 397
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
fix(app): #1536 fix logging format to work with pino-pretty #1593
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this great contribution @mohit-nagaraj! I do have some feedback:
For your new flag to work as expected, it needs to be registered with the command. You can see how that was done with other flags for the logs
command here:
Lines 167 to 188 in 7f7a3c0
logs := CmdBuilder( | |
cmd, | |
RunAppsGetLogs, | |
"logs <app id> <component name (defaults to all components)>", | |
"Retrieves logs", | |
`Retrieves component logs for a deployment of an app. | |
Three types of logs are supported and can be specified with the --`+doctl.ArgAppLogType+` flag: | |
- build | |
- deploy | |
- run | |
- run_restarted | |
For more information about logs, see [How to View Logs](https://www.digitalocean.com/docs/app-platform/how-to/view-logs/). | |
`, | |
Writer, | |
aliasOpt("l"), | |
) | |
AddStringFlag(logs, doctl.ArgAppDeployment, "", "", "Retrieves logs for a specific deployment ID. Defaults to current deployment.") | |
AddStringFlag(logs, doctl.ArgAppLogType, "", strings.ToLower(string(godo.AppLogTypeRun)), "Retrieves logs for a specific log type. Defaults to run logs.") | |
AddBoolFlag(logs, doctl.ArgAppLogFollow, "f", false, "Returns logs as they are emitted by the app.") | |
AddIntFlag(logs, doctl.ArgAppLogTail, "", -1, "Specifies the number of lines to show from the end of the log.") |
That is also where you add the information that shows in the help output.
I also think output-json
might not be the best name for this flag. The output is only in JSON if your application logs in JSON. If you log in plain text, using the output-json
would still produce plain text. Maybe something like no-prefix
as it removes the prefixes from the logs? We could provide a hint in the help text that it useful for JSON structured logs.
Sure got it fixing them |
Hey I updated code as specified, Could you re-review them will implement any of the changes you say |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM! Thanks again for the great contribution!
Summary
This PR introduces a new --output-json flag for the RunAppsGetLogs function in the DigitalOcean CLI (doctl). When this flag is used, the logs are outputted in JSON format without the service name and timestamp prefix.
Changes Made
Closes #1536