MCPcopy Create free account
hub / github.com/conforma/cli / LoggerFor

Function LoggerFor

acceptance/log/log.go:158–180  ·  view source on GitHub ↗

LoggerFor returns the logger for the provided Context. Each call for a new context creates a per-scenario temp file for log isolation.

(ctx context.Context)

Source from the content-addressed store, hash-verified

156// LoggerFor returns the logger for the provided Context. Each call for
157// a new context creates a per-scenario temp file for log isolation.
158func LoggerFor(ctx context.Context) (Logger, context.Context) {
159 if logger, ok := ctx.Value(loggerKey).(Logger); ok {
160 return logger, ctx
161 }
162
163 id := counter.Add(1)
164
165 f, err := os.CreateTemp("", fmt.Sprintf("scenario-%010d-*.log", id))
166 if err != nil {
167 panic(fmt.Sprintf("failed to create scenario log file: %v", err))
168 }
169
170 delegate := &fileLogger{file: f}
171
172 logger := logger{
173 t: delegate,
174 id: id,
175 name: "*",
176 path: f.Name(),
177 }
178
179 return &logger, context.WithValue(ctx, loggerKey, &logger)
180}

Callers 15

initializeScenarioFunction · 0.92
startStubRegistryFunction · 0.92
AddStepsToFunction · 0.92
startStubGitServerFunction · 0.92
AddStepsToFunction · 0.92
BuildSnapshotArtifactMethod · 0.92
StartFunction · 0.92
StopMethod · 0.92
DestroyFunction · 0.92
StartWiremockFunction · 0.92
AddStepsToFunction · 0.92
ecCommandIsRunWithFunction · 0.92

Calls 1

NameMethod · 0.65

Tested by 6

initializeScenarioFunction · 0.74
TestLoggerWritesToFileFunction · 0.68
TestLoggerCachingFunction · 0.68
TestLoggerUniquenessFunction · 0.68
TestLoggerIsolationFunction · 0.68