Skip to content
SHC Docs

Logs module

Source: modules/logs/.

CLIshc logs
Subcommands0
HTTP endpointssee the route reference
Events emitted
Error codessee the error code reference
Service classesLogsService
Cross-module depsapp, node
modules/logs/
├── command.go
├── router.go
├── service.go
├── types.go
└── commands/

Routes are listed in the generated route reference; request/response notes live in the API reference.

The logs module is a unified retrieval facade over docker logs / docker service logs for a stack’s containers. It translates a request expressed in SHC terms (tenant, stack, environment, service, time window) into the right Docker command and run it on the node that owns the stack.

Public surface: the single LogsService type in service.go, with two entry points:

  • GetLogs(...) — batch retrieval, returns a bounded chunk of log lines as a single response (capped by tail). Used by shc logs and the UI’s log viewer.
  • StreamLogs(...) — channel of log lines for follow-mode (shc logs -f). Streams from the owning node through SSE when remote.

The heavy lifting is all in the private methods:

  • buildLogsCommand — renders the correct docker invocation (Compose vs Swarm stack) using the correct project name (BuildDockerProjectName).
  • execLocal / streamLocal — shell out when the stack is on the local node.
  • getRemoteLogs — when the stack is on another node, use the internal_api client to tunnel the request; the far side runs the same LogsService and streams bytes back.
  • parseSince — accepts durations (1h, 30m) and absolute timestamps, mapping both to what docker logs --since expects.

What the logs module does not own: the log collector / shipper (that is the OTel collector pipeline — subsystems/impl/stack_reconcile_otel.go + OpenObserve export), the audit log (that is audit), or SSE multiplexing (that is events). This module is purely a query facade over Docker’s native log storage.