-
Notifications
You must be signed in to change notification settings - Fork 262
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
Improvement: add --raw
flag to run
, deploy
command
#1653
Improvement: add --raw
flag to run
, deploy
command
#1653
Conversation
modify: logs() argument modify: output log
cargo-shuttle/src/args.rs
Outdated
#[arg(short = 'F', long)] | ||
pub format: Option<LogFormat>, | ||
} | ||
|
||
#[derive(ValueEnum, Clone, Debug, strum::Display, strum::EnumIter)] | ||
#[strum(serialize_all = "kebab-case")] | ||
pub enum LogFormat { | ||
/// Don't display timestamps and log origin tags | ||
Raw, | ||
} |
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.
I defined an enum LogFormat
to allow logs commands to be output in various formats in the future. (This is why we call it --raw
-> --format raw
). If this change is not good, undo it.
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.
Since raw
is the only supported format, and the other commands take --raw
, we could keep this as --raw
for consistency.
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.
I have standardized on --raw
to be consistent with other commands. Thanks for your comments!
I tried to see what happens when I look at the logs in json format. One problem: the important Trying json// cargo-shuttle/src/args.rs
#[derive(ValueEnum, Clone, Debug, strum::Display, strum::EnumIter)]
#[strum(serialize_all = "kebab-case")]
pub enum LogFormat {
/// Don't display timestamps and log origin tags
Raw,
Json
}
// cargo-shuttle/src/lib.rs
for log in logs.into_iter() {
match &args.format {
Some(LogFormat::Raw) => println!("{}", log.get_raw_line()),
Some(LogFormat::Json) => println!("{}", serde_json::to_string(&log)?),
None => println!("{log}"),
}
} cargo run -p cargo-shuttle -- --wd shuttle-examples/rocket/hello-world logs -F json | jq
{
"id": "d282df4b-a264-4839-9dca-dbfb42169867",
"internal_origin": "Deployer",
"timestamp": "2024-03-02T05:40:55.996918Z",
"line": "\u001b[38;5;10m INFO\u001b[39m \u001b[38;5;12mget_deployment\u001b[39m"
}
{
"id": "d282df4b-a264-4839-9dca-dbfb42169867",
"internal_origin": "Deployer",
"timestamp": "2024-03-02T05:48:35.786590Z",
"line": "\u001b[38;5;10m INFO\u001b[39m \u001b[38;5;12mget_logs\u001b[39m"
} |
--raw
flag for run
, deploy
command
--raw
flag for run
, deploy
command--raw
flag to run
, deploy
command
Description of change
Implemented --raw flag for cargo-shuttle
run
,deploy
command.LogsArgs
to organize thelog()
arguments.Closes #1632
How has this been tested? (if applicable)
deply
run