mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(logs): improvements to searching
This commit is contained in:
@@ -32,7 +32,7 @@ export const setupDockerContainerLogsWebSocketServer = (
|
||||
const containerId = url.searchParams.get("containerId");
|
||||
const tail = url.searchParams.get("tail");
|
||||
const search = url.searchParams.get("search");
|
||||
const since = url.searchParams.get("since")
|
||||
const since = url.searchParams.get("since");
|
||||
const serverId = url.searchParams.get("serverId");
|
||||
const { user, session } = await validateWebSocketRequest(req);
|
||||
|
||||
@@ -53,9 +53,12 @@ export const setupDockerContainerLogsWebSocketServer = (
|
||||
const client = new Client();
|
||||
client
|
||||
.once("ready", () => {
|
||||
const command = `
|
||||
bash -c "docker container logs --timestamps --tail ${tail} ${since === "all" ? "" : `--since ${since}`} --follow ${containerId} | grep -i '${search}'"
|
||||
`;
|
||||
const baseCommand = `docker container logs --timestamps --tail ${tail} ${
|
||||
since === "all" ? "" : `--since ${since}`
|
||||
} --follow ${containerId}`;
|
||||
const command = search
|
||||
? `${baseCommand} 2>&1 | grep -iF '${search}'`
|
||||
: baseCommand;
|
||||
client.exec(command, (err, stream) => {
|
||||
if (err) {
|
||||
console.error("Execution error:", err);
|
||||
@@ -93,11 +96,17 @@ export const setupDockerContainerLogsWebSocketServer = (
|
||||
});
|
||||
} else {
|
||||
const shell = getShell();
|
||||
const baseCommand = `docker container logs --timestamps --tail ${tail} ${
|
||||
since === "all" ? "" : `--since ${since}`
|
||||
} --follow ${containerId}`;
|
||||
const command = search
|
||||
? `${baseCommand} 2>&1 | grep -iF '${search}'`
|
||||
: baseCommand;
|
||||
const ptyProcess = spawn(
|
||||
shell,
|
||||
[
|
||||
"-c",
|
||||
`docker container logs --timestamps --tail ${tail} ${since === "all" ? "" : `--since ${since}`} --follow ${containerId} | grep -i '${search}'`,
|
||||
command,
|
||||
],
|
||||
{
|
||||
name: "xterm-256color",
|
||||
|
||||
Reference in New Issue
Block a user