Skip to content

Commit 41a34ad

Browse files
authored
Add Extra Log Messages to Improve Debugging Experience (#906)
This adds more debugging statements for connections and ai chat, in order to provide us more context if users run into bugs.
1 parent cacde1b commit 41a34ad

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

pkg/remote/conncontroller/conncontroller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ func (conn *SSHConn) WithLock(fn func()) {
416416
func (conn *SSHConn) connectInternal(ctx context.Context) error {
417417
client, err := remote.ConnectToClient(ctx, conn.Opts) //todo specify or remove opts
418418
if err != nil {
419+
log.Printf("error: failed to connect to client %s: %v\n", conn.GetName(), err)
419420
return err
420421
}
421422
fmtAddr := knownhosts.Normalize(fmt.Sprintf("%s@%s", client.User(), client.RemoteAddr().String()))
@@ -425,14 +426,17 @@ func (conn *SSHConn) connectInternal(ctx context.Context) error {
425426
})
426427
err = conn.OpenDomainSocketListener()
427428
if err != nil {
429+
log.Printf("error: unable to open domain socket listener for %s: %v\n", conn.GetName(), err)
428430
return err
429431
}
430432
installErr := conn.CheckAndInstallWsh(ctx, clientDisplayName, nil)
431433
if installErr != nil {
434+
log.Printf("error: unable to install wsh shell extensions for %s: %v\n", conn.GetName(), err)
432435
return fmt.Errorf("conncontroller %s wsh install error: %v", conn.GetName(), installErr)
433436
}
434437
csErr := conn.StartConnServer()
435438
if csErr != nil {
439+
log.Printf("error: unable to start conn server for %s: %v\n", conn.GetName(), csErr)
436440
return fmt.Errorf("conncontroller %s start wsh connserver error: %v", conn.GetName(), csErr)
437441
}
438442
conn.HasWaiter.Store(true)

pkg/remote/sshclient.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ func createHostKeyCallback(opts *SSHOpts) (ssh.HostKeyCallback, HostKeyAlgorithm
473473
offendingKeysFmt = append(offendingKeysFmt, formattedKey)
474474
}
475475
// todo
476-
_ = fmt.Sprintf("**WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!**\n\n"+
476+
errorMsg := fmt.Sprintf("**WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!**\n\n"+
477477
"If this is not expected, it is possible that someone could be trying to "+
478478
"eavesdrop on you via a man-in-the-middle attack. "+
479479
"Alternatively, the host you are connecting to may have changed its key. "+
@@ -485,6 +485,7 @@ func createHostKeyCallback(opts *SSHOpts) (ssh.HostKeyCallback, HostKeyAlgorithm
485485
"%s\n\n"+
486486
"**Offending Keys** \n"+
487487
"%s", key.Type(), correctKeyFingerprint, strings.Join(bulletListKnownHosts, " \n"), strings.Join(offendingKeysFmt, " \n"))
488+
log.Print(errorMsg)
488489
//update := scbus.MakeUpdatePacket()
489490
// create update into alert message
490491

pkg/wshrpc/wshserver/wshserver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ func (ws *WshServer) StreamTestCommand(ctx context.Context) chan wshrpc.RespOrEr
7575

7676
func (ws *WshServer) StreamWaveAiCommand(ctx context.Context, request wshrpc.OpenAiStreamRequest) chan wshrpc.RespOrErrorUnion[wshrpc.OpenAIPacketType] {
7777
if request.Opts.BaseURL == "" && request.Opts.APIToken == "" {
78+
log.Print("sending ai chat message to waveterm default endpoint with openai\n")
7879
return waveai.RunCloudCompletionStream(ctx, request)
7980
}
81+
log.Printf("sending ai chat message to user-configured endpoint %s\n", request.Opts.BaseURL)
8082
return waveai.RunLocalCompletionStream(ctx, request)
8183
}
8284

0 commit comments

Comments
 (0)