Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

feat(logging): Migrate to Go structured logging with slog

Đang mở
#970 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
go
Lĩnh vực
backend, cli

Hướng nghiên cứu

Trước tiên, hãy kiểm kê các chỗ sử dụng log.Printf và fmt.Printf trong pkg/unikontainers/, pkg/containerd-shim/ và cmd/urunc/, sau đó kiểm tra luồng khởi động CLI để xác định nơi có thể khởi tạo các flag. Công việc hoàn tất khi các khu vực đó sử dụng thiết lập slog tập trung, các flag về mức log và định dạng log hoạt động, đầu ra JSON hợp lệ và hành vi không thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

invalid Stale

Description

urunc currently uses standard Go logging (log package or fmt.Printf) throughout the codebase. This produces unstructured, plain-text logs that are difficult to filter, query, or aggregate in production deployments.

Go 1.21 introduced log/slog, the standard structured logging package. Migrating to slog would enable leveled logging (Debug, Info, Warn, Error), structured key-value pairs, and JSON output.... all without external dependencies.

Proposed Work

  1. Introduce a centralized logger in pkg/ or internal/ using log/slog.
  2. Replace log.Printf / fmt.Printf logging calls with slog.Info, slog.Debug, slog.Error across:
    • pkg/unikontainers/ (VM lifecycle, network, initrd)
    • pkg/containerd-shim/ (shim operations)
    • cmd/urunc/ (CLI commands)
  3. Add a --log-format flag to urunc CLI supporting text (default) and json.
  4. Add a --log-level flag supporting debug, info, warn, error.

Why This Matters

  • Structured logs enable filtering and aggregation in production (e.g., "show all ERROR logs from network setup").
  • JSON output integrates with log aggregation systems (ELK, Loki, CloudWatch).
  • Aligns with modern Go practices (runc, containerd both use structured logging).
  • Zero external dependencies slog is in the standard library.

Acceptance Criteria

  • slog logger is initialized at program startup with configurable level/format.
  • All existing log calls migrated to structured equivalents.
  • urunc --log-level=debug --log-format=json produces valid JSON logs.
  • No functional behavior changes purely logging migration.

Non-Priorities

  • Adding new logging frameworks (zap, zerolog, etc.)slog only.
  • Changing error handling logic.
  • Adding new features beyond logging.

I can start with pkg/unikontainers/ and then move on from there...

Ngôn ngữ chính
Go
Star
306
Fork
214
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
26

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của urunc-dev/urunc

Tất cả issue của urunc-dev/urunc

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.