Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
fix: actor logs base64 (#578)
Browse files Browse the repository at this point in the history
Fixes RVT-4149
  • Loading branch information
NathanFlurry committed Nov 23, 2024
1 parent 8bef249 commit 31bb18b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ anyhow = "1.0"
uuid = { version = "1.11.0", features = ["v4"] }
envy = "0.4.2"
url = { version = "2.5.3", features = ["serde"] }
base64 = "0.22.1"

[build-dependencies]
anyhow = "1.0"
Expand Down
18 changes: 17 additions & 1 deletion packages/cli/src/commands/actor/logs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::*;
use base64::{engine::general_purpose::STANDARD, Engine};
use clap::{Parser, ValueEnum};
use std::process::ExitCode;
use toolchain::rivet_api::{apis, models};
Expand All @@ -23,6 +24,9 @@ pub struct Opts {
#[clap(long)]
id: String,

#[clap(long)]
no_timestamps: bool,

#[clap(long)]
no_follow: bool,
}
Expand Down Expand Up @@ -66,7 +70,19 @@ impl Opts {
}

for (ts, line) in res.timestamps.iter().zip(res.lines.iter()) {
println!("{ts} {line}");
let decoded_line = match STANDARD.decode(line) {
Result::Ok(bytes) => String::from_utf8_lossy(&bytes).to_string(),
Err(_) => {
eprintln!("Failed to decode base64: {line}");
continue;
}
};

if self.no_timestamps {
println!("{decoded_line}");
} else {
println!("{ts} {decoded_line}");
}
}
}

Expand Down

0 comments on commit 31bb18b

Please sign in to comment.