Logs module
Source: modules/logs/.
At a glance
Section titled “At a glance”| CLI | shc logs |
| Subcommands | 0 |
| HTTP endpoints | see the route reference |
| Events emitted | — |
| Error codes | see the error code reference |
| Service classes | LogsService |
| Cross-module deps | app, node |
Source layout
Section titled “Source layout”modules/logs/├── command.go├── router.go├── service.go├── types.go└── commands/CLI entry points
Section titled “CLI entry points”shc logs— view application and service logs
HTTP API
Section titled “HTTP API”Routes are listed in the generated route reference; request/response notes live in the API reference.
Responsibilities
Section titled “Responsibilities”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 bytail). Used byshc logsand 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 theinternal_apiclient to tunnel the request; the far side runs the sameLogsServiceand streams bytes back.parseSince— accepts durations (1h,30m) and absolute timestamps, mapping both to whatdocker logs --sinceexpects.
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.