Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be08606

Browse files
authored
feat: Show plugin version in plugin server logs (#2124)
This could make certain things easier to debug.
1 parent b78cdb4 commit be08606

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

plugin/plugin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ func (p *Plugin) Meta() Meta {
166166
}
167167
}
168168

169+
func (p *Plugin) PackageAndVersion() string {
170+
return fmt.Sprintf("%s/%s/%s@%s", p.team, p.kind, p.name, p.version)
171+
}
172+
169173
// SetSkipUsageClient sets whether the usage client should be skipped
170174
func (p *Plugin) SetSkipUsageClient(v bool) {
171175
p.skipUsageClient = v

serve/info.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package serve
22

33
import (
4-
"fmt"
5-
64
"github.com/spf13/cobra"
75
)
86

@@ -18,7 +16,7 @@ func (s *PluginServe) newCmdPluginInfo() *cobra.Command {
1816
Long: pluginInfoLong,
1917
Args: cobra.ExactArgs(0),
2018
RunE: func(cmd *cobra.Command, _ []string) error {
21-
cmd.Println(fmt.Sprintf("Package and version: %s/%s/%s@%s", s.plugin.Team(), s.plugin.Kind(), s.plugin.Name(), s.plugin.Version()))
19+
cmd.Println("Package and version:", s.plugin.PackageAndVersion())
2220
return nil
2321
},
2422
}

serve/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (s *PluginServe) newCmdPluginServe() *cobra.Command {
222222
}
223223
}()
224224

225-
logger.Info().Str("address", listener.Addr().String()).Msg("Plugin server listening")
225+
logger.Info().Str("address", listener.Addr().String()).Str("plugin", s.plugin.PackageAndVersion()).Msg("Plugin server listening")
226226
if err := grpcServer.Serve(listener); err != nil {
227227
return fmt.Errorf("failed to serve: %w", err)
228228
}

0 commit comments

Comments
 (0)