forked from github-starred/komodo
further improve SearchLog
This commit is contained in:
@@ -130,7 +130,7 @@ impl Resolve<GetLog, User> for State {
|
||||
impl Resolve<SearchLog, User> for State {
|
||||
async fn resolve(
|
||||
&self,
|
||||
SearchLog { deployment, search }: SearchLog,
|
||||
SearchLog { deployment, terms }: SearchLog,
|
||||
user: User,
|
||||
) -> anyhow::Result<Log> {
|
||||
let Deployment {
|
||||
@@ -148,7 +148,7 @@ impl Resolve<SearchLog, User> for State {
|
||||
}
|
||||
let server = Server::get_resource(&server_id).await?;
|
||||
periphery_client(&server)?
|
||||
.request(api::container::GetContainerLogSearch { name, search })
|
||||
.request(api::container::GetContainerLogSearch { name, terms })
|
||||
.await
|
||||
.context("failed at call to periphery")
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ impl Resolve<GetContainerLogSearch> for State {
|
||||
_: (),
|
||||
) -> anyhow::Result<Log> {
|
||||
Ok(
|
||||
docker::container::container_log_search(&req.name, &req.search)
|
||||
docker::container::container_log_search(&req.name, &req.terms)
|
||||
.await,
|
||||
)
|
||||
}
|
||||
@@ -108,10 +108,7 @@ impl Resolve<GetContainerStatsList> for State {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Resolve<StartContainer> for State {
|
||||
#[instrument(
|
||||
name = "StartContainer",
|
||||
skip(self)
|
||||
)]
|
||||
#[instrument(name = "StartContainer", skip(self))]
|
||||
async fn resolve(
|
||||
&self,
|
||||
req: StartContainer,
|
||||
@@ -125,10 +122,7 @@ impl Resolve<StartContainer> for State {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Resolve<StopContainer> for State {
|
||||
#[instrument(
|
||||
name = "StopContainer",
|
||||
skip(self)
|
||||
)]
|
||||
#[instrument(name = "StopContainer", skip(self))]
|
||||
async fn resolve(
|
||||
&self,
|
||||
req: StopContainer,
|
||||
@@ -147,10 +141,7 @@ impl Resolve<StopContainer> for State {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Resolve<RemoveContainer> for State {
|
||||
#[instrument(
|
||||
name = "RemoveContainer",
|
||||
skip(self)
|
||||
)]
|
||||
#[instrument(name = "RemoveContainer", skip(self))]
|
||||
async fn resolve(
|
||||
&self,
|
||||
req: RemoveContainer,
|
||||
@@ -169,10 +160,7 @@ impl Resolve<RemoveContainer> for State {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Resolve<RenameContainer> for State {
|
||||
#[instrument(
|
||||
name = "RenameContainer",
|
||||
skip(self)
|
||||
)]
|
||||
#[instrument(name = "RenameContainer", skip(self))]
|
||||
async fn resolve(
|
||||
&self,
|
||||
req: RenameContainer,
|
||||
@@ -192,10 +180,7 @@ impl Resolve<RenameContainer> for State {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Resolve<PruneContainers> for State {
|
||||
#[instrument(
|
||||
name = "PruneContainers",
|
||||
skip(self)
|
||||
)]
|
||||
#[instrument(name = "PruneContainers", skip(self))]
|
||||
async fn resolve(
|
||||
&self,
|
||||
_: PruneContainers,
|
||||
@@ -209,10 +194,7 @@ impl Resolve<PruneContainers> for State {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Resolve<Deploy> for State {
|
||||
#[instrument(
|
||||
name = "Deploy",
|
||||
skip(self)
|
||||
)]
|
||||
#[instrument(name = "Deploy", skip(self))]
|
||||
async fn resolve(
|
||||
&self,
|
||||
Deploy {
|
||||
|
||||
@@ -30,10 +30,12 @@ pub async fn container_log(container_name: &str, tail: u64) -> Log {
|
||||
#[instrument(level = "debug")]
|
||||
pub async fn container_log_search(
|
||||
container_name: &str,
|
||||
search: &str,
|
||||
terms: &[String],
|
||||
) -> Log {
|
||||
let command =
|
||||
format!("docker logs {container_name} --tail 5000 | grep {search}");
|
||||
let command = format!(
|
||||
"docker logs {container_name} --tail 5000 | grep -E '{}'",
|
||||
terms.join("|")
|
||||
);
|
||||
run_monitor_command("get container log grep", command).await
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ pub struct SearchLog {
|
||||
/// Id or name
|
||||
#[serde(alias = "id", alias = "name")]
|
||||
pub deployment: String,
|
||||
pub search: String,
|
||||
pub terms: Vec<String>,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
|
||||
@@ -32,7 +32,7 @@ fn default_tail() -> u64 {
|
||||
#[response(Log)]
|
||||
pub struct GetContainerLogSearch {
|
||||
pub name: String,
|
||||
pub search: String,
|
||||
pub terms: Vec<String>,
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user