Add `getLogs()` and a line-based log consumer
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 62/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- docker, node.js, typescript
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.6k
- Fork
- 277
- Merge trung bình
- 1 ngày 53 phút
- Pull request đã merge (30 ngày)
- 58
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của testcontainers/testcontainers-node
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
testcontainers/testcontainers-node#1539 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
testcontainers/testcontainers-node#1533 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
testcontainers/testcontainers-node#1531 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
testcontainers/testcontainers-node#1529 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
testcontainers/testcontainers-node#1528 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của testcontainers/testcontainers-node
Issue tương tự
-
engine-rs P3 review-deferral wasm
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
maniator/verticopolis#1154 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
telerik/kendo-react#3861 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[bug]: use-mobile.ts uses pixel logic, causing UI state de-sync with Tailwind CSS rem breakpointsĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100