@@ -233,7 +233,7 @@ func (w *Worker) runPrecheck(lab, outputDir, modelName string) error {
233
233
}
234
234
chatlogDir := path .Join (workDir , "data" , "chatlogs" )
235
235
combinedYAMLPath := path .Join (outputDir , "combined_chatlogs.yaml" )
236
- combinedLogPath := path .Join (outputDir , "combined_chatlogs.log " )
236
+ combinedYAMLHTMLPath := path .Join (outputDir , "combined_chatlogs.html " )
237
237
238
238
defer func () {
239
239
// Move everything from chatlogDir to outputDir
@@ -244,7 +244,7 @@ func (w *Worker) runPrecheck(lab, outputDir, modelName string) error {
244
244
}
245
245
246
246
var combinedLogs []map [string ]interface {}
247
- var combinedLogsText strings. Builder
247
+ var fileNames [] string
248
248
249
249
for _ , file := range chatlogFiles {
250
250
if strings .HasSuffix (file .Name (), ".yaml" ) {
@@ -261,27 +261,19 @@ func (w *Worker) runPrecheck(lab, outputDir, modelName string) error {
261
261
continue
262
262
}
263
263
combinedLogs = append (combinedLogs , logData )
264
- } else if strings .HasSuffix (file .Name (), ".log" ) {
265
- // Read individual log files
266
- content , err := os .ReadFile (path .Join (chatlogDir , file .Name ()))
267
- if err != nil {
268
- w .logger .Errorf ("Could not read log file %s: %v" , file .Name (), err )
269
- continue
270
- }
271
- // Add delimiter before each log
272
- combinedLogsText .WriteString (fmt .Sprintf ("\n \n ----- %s -----\n \n \n " , file .Name ()))
273
- combinedLogsText .Write (content )
274
- }
275
264
265
+ }
276
266
// Move individual file to outputDir
277
267
if err := os .Rename (path .Join (chatlogDir , file .Name ()), path .Join (outputDir , file .Name ())); err != nil {
278
268
w .logger .Errorf ("Could not move file %s: %v" , file .Name (), err )
279
269
continue
280
270
}
271
+ fileNames = append (fileNames , file .Name ())
281
272
}
282
273
283
274
// Write the combined YAML file
284
275
if len (combinedLogs ) > 0 {
276
+ // standard combined yaml file
285
277
combinedYAML , err := yaml .Marshal (combinedLogs )
286
278
if err != nil {
287
279
w .logger .Errorf ("Could not marshal combined YAML data: %v" , err )
@@ -292,15 +284,27 @@ func (w *Worker) runPrecheck(lab, outputDir, modelName string) error {
292
284
return
293
285
}
294
286
w .logger .Infof ("Combined YAML file written to %s" , combinedYAMLPath )
295
- }
296
287
297
- // Write the combined log file
298
- if combinedLogsText .Len () > 0 {
299
- if err := os .WriteFile (combinedLogPath , []byte (combinedLogsText .String ()), 0644 ); err != nil {
300
- w .logger .Errorf ("Could not write combined log file: %v" , err )
301
- return
288
+ combinedLogHtmlFile , err := os .Create (combinedYAMLHTMLPath )
289
+ if err != nil {
290
+ w .logger .Errorf ("Could not create combined_yaml.html: %v" , err )
291
+ }
292
+ defer combinedLogHtmlFile .Close ()
293
+
294
+ // build yamlEntries array from files
295
+ var yamlEntries []string
296
+ var yamlFileBytes []byte
297
+ for _ , yamlFile := range combinedLogs {
298
+ yamlFileBytes , err = yaml .Marshal (yamlFile )
299
+ if err != nil {
300
+ w .logger .Errorf ("Could not create unmarshal map to yaml: %v" , err )
301
+ }
302
+ yamlEntries = append (yamlEntries , string (yamlFileBytes ))
303
+ }
304
+ if err := generateAllHTML (combinedLogHtmlFile , yamlEntries , fileNames ); err != nil {
305
+ w .logger .Errorf ("Could not generate index.html: %v" , err )
302
306
}
303
- w .logger .Infof ("Combined log file written to %s" , combinedLogPath )
307
+ w .logger .Infof ("Combined log file written to %s" , combinedLogHtmlFile )
304
308
}
305
309
}()
306
310
0 commit comments