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

fix: actor logs base64 #578

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading