MCPcopy Create free account
hub / github.com/containerd/nerdctl / viewLogsJSONFile

Function viewLogsJSONFile

pkg/logging/json_logger.go:145–161  ·  view source on GitHub ↗

Loads log entries from logfiles produced by the json-logger driver and forwards them to the provided io.Writers after applying the provided logging options.

(lvopts LogViewOptions, stdout, stderr io.Writer, stopChannel chan os.Signal)

Source from the content-addressed store, hash-verified

143// Loads log entries from logfiles produced by the json-logger driver and forwards
144// them to the provided io.Writers after applying the provided logging options.
145func viewLogsJSONFile(lvopts LogViewOptions, stdout, stderr io.Writer, stopChannel chan os.Signal) error {
146 logFilePath := jsonfile.Path(lvopts.DatastoreRootPath, lvopts.Namespace, lvopts.ContainerID)
147 if _, err := os.Stat(logFilePath); err != nil {
148 // FIXME: this is a workaround for the actual issue, not a real solution
149 // https://github.com/containerd/nerdctl/issues/3187
150 if errors.Is(err, os.ErrNotExist) {
151 log.L.Warnf("Racing log file creation. Pausing briefly.")
152 time.Sleep(200 * time.Millisecond)
153 _, err = os.Stat(logFilePath)
154 }
155 if err != nil {
156 return fmt.Errorf("failed to stat JSON log file %w", err)
157 }
158 }
159
160 return viewLogsJSONFileDirect(lvopts, logFilePath, stdout, stderr, stopChannel)
161}
162
163// Loads JSON log entries directly from the provided JSON log file.
164// If `LogViewOptions.Follow` is provided, it will refresh and re-read the file until

Callers

nothing calls this directly

Calls 3

PathFunction · 0.92
viewLogsJSONFileDirectFunction · 0.85
StatMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…