()
| 272 | * Initialize per-run logging |
| 273 | */ |
| 274 | export 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. |
no test coverage detected
searching dependent graphs…