@@ -21,15 +21,15 @@ import com.simiacryptus.util.JsonUtil
2121import org.slf4j.LoggerFactory
2222import java.io.File
2323import java.nio.file.Path
24- import java.util.UUID
24+ import java.util.*
2525
2626abstract class PatchApp (
2727 override val root : File ,
28- val session : Session ,
29- val settings : Settings ,
30- val api : ChatClient ,
31- val model : ChatModel ,
32- val promptPrefix : String = """ The following command was run and produced an error:"""
28+ private val session : Session ,
29+ protected val settings : Settings ,
30+ private val api : ChatClient ,
31+ private val model : ChatModel ,
32+ private val promptPrefix : String = """ The following command was run and produced an error:"""
3333) : ApplicationServer(
3434 applicationName = " Magic Code Fixer" ,
3535 path = " /fixCmd" ,
@@ -40,6 +40,11 @@ abstract class PatchApp(
4040 const val tripleTilde = " `" + " ``" // This is a workaround for the markdown parser when editing this file
4141 }
4242
43+ // Add structured logging
44+ private fun logEvent (event : String , data : Map <String , Any ?>) {
45+ log.info(" $event : ${JsonUtil .toJson(data)} " )
46+ }
47+
4348 data class OutputResult (val exitCode : Int , val output : String )
4449
4550 abstract fun codeFiles (): Set <Path >
@@ -103,7 +108,7 @@ abstract class PatchApp(
103108 var workingDirectory : File ? = null ,
104109 var exitCodeOption : String = " nonzero" ,
105110 var additionalInstructions : String = " " ,
106- val autoFix : Boolean ,
111+ val autoFix : Boolean
107112 )
108113
109114 fun run (
@@ -156,6 +161,13 @@ abstract class PatchApp(
156161 ui : ApplicationInterface ,
157162 api : ChatClient ,
158163 ) {
164+ // Add logging for operation start
165+ logEvent(
166+ " Starting fix operation" , mapOf (
167+ " exitCode" to output.exitCode,
168+ " settings" to settings
169+ )
170+ )
159171 Retryable (ui, task) { content ->
160172 fixAllInternal(
161173 settings = settings,
@@ -167,6 +179,13 @@ abstract class PatchApp(
167179 )
168180 content.clear()
169181 " "
182+ }.also {
183+ // Add logging for operation completion
184+ logEvent(
185+ " Fix operation completed" , mapOf (
186+ " success" to true
187+ )
188+ )
170189 }
171190 }
172191
@@ -374,7 +393,4 @@ abstract class PatchApp(
374393 content.append(" <div>${MarkdownUtil .renderMarkdown(markdown!! )} </div>" )
375394 }
376395
377- }
378-
379-
380-
396+ }
0 commit comments