Skip to content
Open
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
2 changes: 2 additions & 0 deletions bin/core/src/api/read/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl Resolve<ReadArgs> for GetStackLog {
services,
tail,
timestamps,
compose_files: stack.compose_file_paths().to_vec(),
})
.await
.context("Failed to get stack log from periphery")?;
Expand Down Expand Up @@ -130,6 +131,7 @@ impl Resolve<ReadArgs> for SearchStackLog {
combinator,
invert,
timestamps,
compose_files: stack.compose_file_paths().to_vec(),
})
.await
.context("Failed to search stack log from periphery")?;
Expand Down
21 changes: 19 additions & 2 deletions bin/periphery/src/api/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,23 @@ impl Resolve<super::Args> for GetComposeLog {
services,
tail,
timestamps,
compose_files,
} = self;
let docker_compose = docker_compose();
let timestamps = if timestamps {
" --timestamps"
} else {
Default::default()
};
// Convert compose files into -f <file> strings
let compose_flags = compose_files
.iter()
.map(|f| format!("-f {}", f))
.collect::<Vec<_>>()
.join(" ");

let command = format!(
"{docker_compose} -p {project} logs --tail {tail}{timestamps} {}",
"{docker_compose} {compose_flags} -p {project} logs --tail {tail}{timestamps} {}",
services.join(" ")
);
Ok(run_komodo_command("get stack log", None, command).await)
Expand All @@ -126,16 +134,25 @@ impl Resolve<super::Args> for GetComposeLogSearch {
combinator,
invert,
timestamps,
compose_files,
} = self;
let docker_compose = docker_compose();

// Convert compose files into -f <file> strings
let compose_flags = compose_files
.iter()
.map(|f| format!("-f {}", f))
.collect::<Vec<_>>()
.join(" ");

let grep = log_grep(&terms, combinator, invert);
let timestamps = if timestamps {
" --timestamps"
} else {
Default::default()
};
let command = format!(
"{docker_compose} -p {project} logs --tail 5000{timestamps} {} 2>&1 | {grep}",
"{docker_compose} {compose_flags} -p {project} logs --tail 5000{timestamps} {} 2>&1 | {grep}",
services.join(" ")
);
Ok(run_komodo_command("Get stack log grep", None, command).await)
Expand Down
4 changes: 4 additions & 0 deletions client/periphery/rs/src/api/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub struct GetComposeLog {
/// Enable `--timestamps`
#[serde(default)]
pub timestamps: bool,
/// Compose files used in the project (required for podman)
pub compose_files: Vec<String>,
}

fn default_tail() -> u64 {
Expand Down Expand Up @@ -92,6 +94,8 @@ pub struct GetComposeLogSearch {
/// Enable `--timestamps`
#[serde(default)]
pub timestamps: bool,
/// Compose files used in the project (required for podman)
pub compose_files: Vec<String>,
}

//
Expand Down