MCPcopy
hub / github.com/promptfoo/promptfoo / initializeRunLogging

Function initializeRunLogging

src/logger.ts:274–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272 * Initialize per-run logging
273 */
274export function initializeRunLogging(): void {
275 try {
276 const date = new Date();
277 if (!getEnvBool('PROMPTFOO_DISABLE_DEBUG_LOG', false)) {
278 cliState.debugLogFile = createRunLogFile('debug', { date });
279 const runLogTransport = new winston.transports.File({
280 filename: cliState.debugLogFile,
281 level: 'debug', // Capture all levels in the file
282 format: winston.format.combine(winston.format.simple(), fileFormatter),
283 });
284 winstonLogger.add(runLogTransport);
285 }
286
287 if (!getEnvBool('PROMPTFOO_DISABLE_ERROR_LOG', false)) {
288 cliState.errorLogFile = createRunLogFile('error', { date });
289 const errorLogTransport = new winston.transports.File({
290 filename: cliState.errorLogFile,
291 level: 'error',
292 format: winston.format.combine(winston.format.simple(), fileFormatter),
293 });
294 winstonLogger.add(errorLogTransport);
295 }
296 } catch (error) {
297 logger.warn(`Error creating run log file: ${error}`);
298 }
299}
300
301/**
302 * Creates a logger method for the specified log level.

Callers 1

mainFunction · 0.90

Calls 3

getEnvBoolFunction · 0.90
createRunLogFileFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…