Add `getLogs()` and a line-based log consumer
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 62/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- docker, node.js, typescript
Línea de trabajo
Read logs in packages/testcontainers/src/generic-<container>/started-generic-<container>.ts, withLogConsumer in packages/testcontainers/src/generic-<container>/generic-<container>.ts, and the StartedTestContainer interface and forwarder in packages/testcontainers/src/test-<container>.ts. Trace how the existing streams expose stdout and stderr, then add the string retrieval options and a distinct line consumer while preserving stream access. Done when the documented examples work and the API changes are covered.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
Reading a container's logs takes stream handling in both places it is offered.
After start, logs() resolves to a Readable. Getting text to assert on means collecting it by hand:
const stream = await container.logs();
const lines: string[] = [];
stream.on("data", (line) => lines.push(line));
await new Promise((resolve) => stream.on("end", resolve));
Before start, withLogConsumer hands over the raw stream, with stderr delivered on a custom err event:
.withLogConsumer((stream) => {
stream.on("data", (line) => console.log(line));
stream.on("err", (line) => console.error(line));
stream.on("end", () => console.log("Stream closed"));
})
Expected
await container.getLogs()resolves to the logs so far as a string, with options forsince,tailand stdout/stderr.- A line-based consumer, so the common case is one line:
.withLogConsumer((line) => console.log(line))or a helper such asLogConsumers.toConsole({ prefix: "redis" }). - The stream forms stay for callers who want them.
Where
logsinpackages/testcontainers/src/generic-container/started-generic-container.tswithLogConsumerinpackages/testcontainers/src/generic-container/generic-container.tspackages/testcontainers/src/test-container.ts
Notes
- Java has
String getLogs()andgetLogs(OutputType...), andwithLogConsumer(Consumer<OutputFrame>), where each frame carries its text and whether it is stdout or stderr. Go'sLogConsumer.Accept(Log)is also per entry. - A function argument cannot tell a line consumer from a stream consumer, so the line form needs its own method name or a helper that returns a stream consumer.
- Related: #1506. A string of recent logs is also what a start failure wants to include.
Dependencies
- Nothing blocks this. It can start now.
- Changes
StartedTestContainer, which today means the interface,StartedGenericContainerand the forwarder onAbstractStartedContainer. Several other issues do the same. The edits do not overlap, so they can go in parallel.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.6k
- Forks
- 274
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 44
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testcontainers/testcontainers-node
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
testcontainers/testcontainers-node#1539 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
testcontainers/testcontainers-node#1533 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
testcontainers/testcontainers-node#1531 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
testcontainers/testcontainers-node#1529 ·
Los mantenedores suelen responder en 1 día
-
enhancement minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
testcontainers/testcontainers-node#1528 ·
Los mantenedores suelen responder en 1 día
Todos los issues de testcontainers/testcontainers-node
Issues similares
-
affected/v17 affected/v18 area/frontend type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
umbraco/Umbraco-CMS#24186 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
better-auth/better-auth#11723 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
area: docs difficulty: easy documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Worker-Erstellung bricht langsame Git-Worktree-Checkouts nach 20 Sekunden abPosiblemente ocupada @KajoVanBuyten la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
AgentSystemLabs/agent-office#367 ·
Los mantenedores suelen responder en 1 día