Skip to content

Commit

Permalink
refactor: Use logger directly instead of creating a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
alexluong committed Jul 29, 2024
1 parent 55622a6 commit a9e3513
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 2 additions & 6 deletions pkg/listen/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,13 @@ func filterConnections(connections []*hookdecksdk.Connection, connectionFilterSt
// When users want to listen to a single source but there is no connection for that source,
// we can help user set up a new connection for it.
func ensureConnections(client *hookdeckclient.Client, connections []*hookdecksdk.Connection, sources []*hookdecksdk.Source, isMultiSource bool, connectionFilterString string, cliPath string) ([]*hookdecksdk.Connection, error) {
l := log.StandardLogger()

if len(connections) > 0 || isMultiSource {
msg := fmt.Sprintf("Connection exists for Source \"%s\", Connection \"%s\", and CLI path \"%s\"", sources[0].Name, connectionFilterString, cliPath)
l.Debug(msg)
log.Debug(fmt.Sprintf("Connection exists for Source \"%s\", Connection \"%s\", and CLI path \"%s\"", sources[0].Name, connectionFilterString, cliPath))

return connections, nil
}

msg := fmt.Sprintf("No connection found. Creating a connection for Source \"%s\", Connection \"%s\", and CLI path \"%s\"", sources[0].Name, connectionFilterString, cliPath)
l.Debug(msg)
log.Debug(fmt.Sprintf("No connection found. Creating a connection for Source \"%s\", Connection \"%s\", and CLI path \"%s\"", sources[0].Name, connectionFilterString, cliPath))

connectionDetails := struct {
Label string `survey:"label"`
Expand Down
3 changes: 1 addition & 2 deletions pkg/listen/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ Specify a single destination to update the CLI path. For example, pass a connect
*connections[0].Destination.CliPath != "" &&
*connections[0].Destination.CliPath != flags.CliPath {

l := log.StandardLogger()
updateMsg := fmt.Sprintf("Updating destination CLI path from \"%s\" to \"%s\"", *connections[0].Destination.CliPath, flags.CliPath)
l.Debug(updateMsg)
log.Debug(updateMsg)

path := flags.CliPath
_, err := sdkClient.Destination.Update(context.Background(), connections[0].Destination.Id, &hookdecksdk.DestinationUpdateRequest{
Expand Down

0 comments on commit a9e3513

Please sign in to comment.