@@ -67,19 +67,15 @@ func (c *AzureClient) GetChatCompletionStream(ctx context.Context, req ChatCompl
6767 inferenceURL = c .cfg .InferenceRoot + "/" + c .cfg .InferencePath
6868 }
6969
70- // TODO: remove logging
71- // Write request details to llm.http file for debugging
72- if os . Getenv ( "DEBUG" ) != "" {
73- httpFile , err := os .OpenFile ("llm.http" , os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0644 )
70+ // Write request details to specified log file for debugging
71+ httpLogFile := HTTPLogFileFromContext ( ctx )
72+ if httpLogFile != "" {
73+ logFile , err := os .OpenFile (httpLogFile , os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0644 )
7474 if err == nil {
75- defer httpFile .Close ()
76- fmt .Fprintf (httpFile , "### %s\n " , time .Now ().Format (time .RFC3339 ))
77- fmt .Fprintf (httpFile , "POST %s\n " , inferenceURL )
78- fmt .Fprintf (httpFile , "Authorization: Bearer {{$processEnv GITHUB_TOKEN}}\n " )
79- fmt .Fprintf (httpFile , "Content-Type: application/json\n " )
80- fmt .Fprintf (httpFile , "x-ms-useragent: github-cli-models\n " )
81- fmt .Fprintf (httpFile , "x-ms-user-agent: github-cli-models\n " )
82- fmt .Fprintf (httpFile , "\n %s\n \n " , string (bodyBytes ))
75+ defer logFile .Close ()
76+ fmt .Fprintf (logFile , "### %s\n POST %s\n Authorization: Bearer {{$processEnv GITHUB_TOKEN}}\n Content-Type: application/json\n x-ms-useragent: github-cli-models\n x-ms-user-agent: github-cli-models\n \n %s\n \n " ,
77+ const logFormat = "### %s\n POST %s\n Authorization: Bearer {{$processEnv GITHUB_TOKEN}}\n Content-Type: application/json\n x-ms-useragent: github-cli-models\n x-ms-user-agent: github-cli-models\n \n %s\n \n "
78+ fmt .Fprintf (logFile , logFormat , time .Now ().Format (time .RFC3339 ), inferenceURL , string (bodyBytes ))
8379 }
8480 }
8581
0 commit comments