Skip to content
Permalink
Browse files

improved startup logging with version information

streamlines the startup logging of inlets to always print the welcome
message first even if there are errors later in the process. reporting
the version number and component started helps the operator to exactly
know what's going on. printing the welcome message like the other log
lines unifies the output in a consistent way.

Signed-off-by: Tobias Brunner <tobias.brunner@vshn.ch>
  • Loading branch information...
tobru authored and alexellis committed Oct 4, 2019
1 parent bac2bac commit d8db8b73353de3638edd276472f4111e0996754d
Showing with 16 additions and 10 deletions.
  1. +4 −2 cmd/client.go
  2. +9 −6 cmd/inlets.go
  3. +3 −2 cmd/server.go
@@ -61,6 +61,10 @@ Note: You can pass the --token argument followed by a token value to both the se

// runClient does the actual work of reading the arguments passed to the client sub command.
func runClient(cmd *cobra.Command, _ []string) error {

log.Printf("%s", WelcomeMessage)
log.Printf("Starting client - version %s", getVersion())

upstream, err := cmd.Flags().GetString("upstream")
if err != nil {
return errors.Wrap(err, "failed to get 'upstream' value")
@@ -110,8 +114,6 @@ func runClient(cmd *cobra.Command, _ []string) error {
log.Printf("Token: %q", token)
}

fmt.Printf(WelcomeMessage)

inletsClient := client.Client{
Remote: remote,
UpstreamMap: upstreamMap,
@@ -13,7 +13,7 @@ var (
GitCommit string
)

const WelcomeMessage = "Welcome to inlets.dev! Find out more at https://github.com/alexellis/inlets\n\n"
const WelcomeMessage = "Welcome to inlets.dev! Find out more at https://github.com/alexellis/inlets"

func init() {
inletsCmd.AddCommand(versionCmd)
@@ -43,14 +43,17 @@ var versionCmd = &cobra.Command{
Run: parseBaseCommand,
}

func getVersion() string {
if len(Version) != 0 {
return Version
}
return "dev"
}

func parseBaseCommand(_ *cobra.Command, _ []string) {
printLogo()

if len(Version) == 0 {
fmt.Println("Version: dev")
} else {
fmt.Println("Version:", Version)
}
fmt.Println("Version:", getVersion())
fmt.Println("Git Commit:", GitCommit)
os.Exit(0)
}
@@ -40,6 +40,9 @@ func init() {
// runServer does the actual work of reading the arguments passed to the server sub command.
func runServer(cmd *cobra.Command, _ []string) error {

log.Printf("%s", WelcomeMessage)
log.Printf("Starting server - version %s", getVersion())

tokenFile, err := cmd.Flags().GetString("token-from")
if err != nil {
return errors.Wrap(err, "failed to get 'token-from' value.")
@@ -88,8 +91,6 @@ func runServer(cmd *cobra.Command, _ []string) error {
return errors.Wrap(err, "failed to get the 'disable-transport-wrapping' value.")
}

fmt.Printf(WelcomeMessage)

inletsServer := server.Server{
Port: port,
ControlPort: controlPort,

0 comments on commit d8db8b7

Please sign in to comment.
You can’t perform that action at this time.